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; 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