From d0ea20a17d8256f2050b5797399f9ce2c7e989e1 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Wed, 1 May 2019 12:33:50 -0700 Subject: [PATCH 1/2] Check directly for // in resolveUrl because it isn't a valid URL --- lib/utils/resolve-url.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/utils/resolve-url.js b/lib/utils/resolve-url.js index 96bb61004c..ae5e5e2ad5 100644 --- a/lib/utils/resolve-url.js +++ b/lib/utils/resolve-url.js @@ -28,6 +28,9 @@ 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; From 5537380852b1cc0a0ab660d0d80a4eabf6a2859a Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 2 May 2019 13:24:36 -0700 Subject: [PATCH 2/2] Add test for resolveUrl('//') --- test/unit/resolveurl.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/resolveurl.html b/test/unit/resolveurl.html index 0d9a193a78..26d708b682 100644 --- a/test/unit/resolveurl.html +++ b/test/unit/resolveurl.html @@ -162,6 +162,14 @@ assert.equal(actual, expected); }); + test('resolveUrl when called with //', function () { + const el = document.querySelector('x-resolve'); + const expected = '//'; + const actual = + el.resolveUrl('//', 'https://example.org/bar'); + assert.equal(actual, expected); + }); + test('resolveUrl api with assetpath', function() { var el = document.createElement('p-r-ap'); // Manually calculate expected URL, to avoid dependence on