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<
153
153
}
154
154
155
155
const getUrlPrefix = ( input : string ) : string => {
156
- if ( URL . canParse ( input ) ) {
156
+ if ( canParseUrl ( input ) ) {
157
157
const url = new URL ( input ) . toString ( )
158
158
if ( url . endsWith ( '/' ) ) return url . slice ( 0 , - 1 )
159
159
return url
@@ -166,3 +166,13 @@ const getUrlPrefix = (input: string): string => {
166
166
`Cannot resolve origin from ${ input } in a non-browser environment` ,
167
167
)
168
168
}
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