Skip to content

Commit

Permalink
Add URL try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed May 7, 2019
1 parent 413ef2f commit 940b3cd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/utils/resolve-url.js
Expand Up @@ -28,9 +28,6 @@ export function resolveUrl(url, baseURI) {
if (url && ABS_URL.test(url)) {
return url;
}
if (url === '//') {
return url;
}
// Lazy feature detection.
if (workingURL === undefined) {
workingURL = false;
Expand All @@ -46,7 +43,12 @@ export function resolveUrl(url, baseURI) {
baseURI = document.baseURI || window.location.href;
}
if (workingURL) {
return (new URL(url, baseURI)).href;
try {
return (new URL(url, baseURI)).href;
} catch (e) {
// Bad url or baseURI structure. Do not attempt to resolve.
return url;
}
}
// Fallback to creating an anchor into a disconnected document.
if (!resolveDoc) {
Expand Down

0 comments on commit 940b3cd

Please sign in to comment.