diff --git a/lib/utils/resolve-url.js b/lib/utils/resolve-url.js index 06b2292e12..96bb61004c 100644 --- a/lib/utils/resolve-url.js +++ b/lib/utils/resolve-url.js @@ -10,7 +10,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN import './boot.js'; let CSS_URL_RX = /(url\()([^)]*)(\))/g; -let ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/; +let ABS_URL = /(^\/[^\/])|(^#)|(^[\w-\d]*:)/; let workingURL; let resolveDoc; /** diff --git a/test/unit/resolveurl.html b/test/unit/resolveurl.html index 7a3106beca..0d9a193a78 100644 --- a/test/unit/resolveurl.html +++ b/test/unit/resolveurl.html @@ -154,6 +154,14 @@ assert.equal(actual, expected); }); + test('resolveUrl when called with a protocol-relative url', function () { + const el = document.querySelector('x-resolve'); + const expected = `https://example.com/foo`; + const actual = + el.resolveUrl('//example.com/foo', '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 diff --git a/test/unit/sub/resolveurl-elements.js b/test/unit/sub/resolveurl-elements.js index 59ba24447e..3fc0faba8b 100644 --- a/test/unit/sub/resolveurl-elements.js +++ b/test/unit/sub/resolveurl-elements.js @@ -31,16 +31,16 @@ class PR extends PolymerElement { } - - Foo - - - - - - Foo + + Foo + + + + + + Foo Foo -
+
Foo Foo Foo