File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
fixtures/react-router-docker/app
packages/cli/templates/react-router-docker/app Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
export const assetBaseUrl = "/assets/" ;
6
6
7
+ /**
8
+ * URL.canParse(props.src)
9
+ * @type {(url: string) => boolean }
10
+ */
11
+ const UrlCanParse = ( url ) => {
12
+ try {
13
+ new URL ( url ) ;
14
+ return true ;
15
+ } catch {
16
+ return false ;
17
+ }
18
+ } ;
19
+
7
20
/**
8
21
* @type {import("@webstudio-is/image").ImageLoader }
9
22
*/
@@ -12,7 +25,7 @@ export const imageLoader = (props) => {
12
25
return props . src ;
13
26
}
14
27
// handle absolute urls
15
- const path = URL . canParse ( props . src ) ? `/${ props . src } ` : props . src ;
28
+ const path = UrlCanParse ( props . src ) ? `/${ props . src } ` : props . src ;
16
29
// https://github.com/unjs/ipx?tab=readme-ov-file#modifiers
17
30
return `/_image/w_${ props . width } ,q_${ props . quality } ${ path } ` ;
18
31
} ;
Original file line number Diff line number Diff line change 4
4
*/
5
5
export const assetBaseUrl = "/assets/" ;
6
6
7
+ /**
8
+ * URL.canParse(props.src)
9
+ * @type {(url: string) => boolean }
10
+ */
11
+ const UrlCanParse = ( url ) => {
12
+ try {
13
+ new URL ( url ) ;
14
+ return true ;
15
+ } catch {
16
+ return false ;
17
+ }
18
+ } ;
19
+
7
20
/**
8
21
* @type {import("@webstudio-is/image").ImageLoader }
9
22
*/
@@ -12,7 +25,7 @@ export const imageLoader = (props) => {
12
25
return props . src ;
13
26
}
14
27
// handle absolute urls
15
- const path = URL . canParse ( props . src ) ? `/${ props . src } ` : props . src ;
28
+ const path = UrlCanParse ( props . src ) ? `/${ props . src } ` : props . src ;
16
29
// https://github.com/unjs/ipx?tab=readme-ov-file#modifiers
17
30
return `/_image/w_${ props . width } ,q_${ props . quality } ${ path } ` ;
18
31
} ;
You can’t perform that action at this time.
0 commit comments