diff --git a/lib/utils/resolve-url.js b/lib/utils/resolve-url.js index ae5e5e2ad5..fa98841801 100644 --- a/lib/utils/resolve-url.js +++ b/lib/utils/resolve-url.js @@ -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; @@ -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) {