From 940b3cdc21ce3329085c94af243f45fcf3a8d1d9 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Tue, 7 May 2019 11:45:20 -0700 Subject: [PATCH] Add URL try/catch --- lib/utils/resolve-url.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) {