create URL fallback only when necessary
This commit is contained in:
parent
12eb243610
commit
14e0a418bf
|
@ -290,9 +290,11 @@ function tryJSONparse(jsonString) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryURL(
|
function tryURL(url) {
|
||||||
url,
|
try {
|
||||||
fallback = {
|
return new URL(url);
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
hash: '',
|
hash: '',
|
||||||
host: '',
|
host: '',
|
||||||
hostname: '',
|
hostname: '',
|
||||||
|
@ -305,11 +307,7 @@ function tryURL(
|
||||||
search: '',
|
search: '',
|
||||||
searchParams: new URLSearchParams(),
|
searchParams: new URLSearchParams(),
|
||||||
username: '',
|
username: '',
|
||||||
}) {
|
};
|
||||||
try {
|
|
||||||
return new URL(url);
|
|
||||||
} catch (e) {
|
|
||||||
return fallback;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user