File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ export class SeamHttpRequest<
153153}
154154
155155const getUrlPrefix = ( input : string ) : string => {
156- if ( URL . canParse ( input ) ) {
156+ if ( canParseUrl ( input ) ) {
157157 const url = new URL ( input ) . toString ( )
158158 if ( url . endsWith ( '/' ) ) return url . slice ( 0 , - 1 )
159159 return url
@@ -166,3 +166,13 @@ const getUrlPrefix = (input: string): string => {
166166 `Cannot resolve origin from ${ input } in a non-browser environment` ,
167167 )
168168}
169+
170+ // UPSTREAM: Prefer URL.canParse when it has wider support.
171+ // https://caniuse.com/mdn-api_url_canparse_static
172+ const canParseUrl = ( input : string ) : boolean => {
173+ try {
174+ return new URL ( input ) != null
175+ } catch {
176+ return false
177+ }
178+ }
You can’t perform that action at this time.
0 commit comments