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