From 3a26bf6bcf50f150af87e26510ac0887fa7a2187 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Thu, 25 Apr 2019 14:06:40 -0700 Subject: [PATCH 1/3] Run resolveUrl for protocol-relative urls This part of ABS_URL is trying to match on absolute paths, like `/images/logo.png` not protocol-relative urls like `//example.com/images/logo.png` Upstreaming cl/245302268 --- lib/utils/resolve-url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; /** From 2947d96ce704f16f2e6625565cd3245df2004266 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Thu, 25 Apr 2019 16:42:36 -0700 Subject: [PATCH 2/3] Added a test and confirmed that it fails without this change. Also cleaned up a some over-aggressive modulizer escaping in resolveurl-elements.js --- test/unit/resolveurl.html | 9 +++++++++ test/unit/sub/resolveurl-elements.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/test/unit/resolveurl.html b/test/unit/resolveurl.html index 7a3106beca..d30803e6e1 100644 --- a/test/unit/resolveurl.html +++ b/test/unit/resolveurl.html @@ -154,6 +154,15 @@ assert.equal(actual, expected); }); + test('resolveUrl when called with a protocol-relative url', function () { + debugger; + 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 From 69068c6cbe1ebc5566b3b22dc913ebdc00660cff Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Thu, 25 Apr 2019 17:12:44 -0700 Subject: [PATCH 3/3] Remove debugger statement --- test/unit/resolveurl.html | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/resolveurl.html b/test/unit/resolveurl.html index d30803e6e1..0d9a193a78 100644 --- a/test/unit/resolveurl.html +++ b/test/unit/resolveurl.html @@ -155,7 +155,6 @@ }); test('resolveUrl when called with a protocol-relative url', function () { - debugger; const el = document.querySelector('x-resolve'); const expected = `https://example.com/foo`; const actual =