Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run resolveUrl for protocol-relative urls #5530

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/resolve-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]*:)/;
rictic marked this conversation as resolved.
Show resolved Hide resolved
let workingURL;
let resolveDoc;
/**
Expand Down
9 changes: 9 additions & 0 deletions test/unit/resolveurl.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions test/unit/sub/resolveurl-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class PR extends PolymerElement {
}
</style>
<div id="div" class="logo" style\$="background-image: url('[[importPath]]foo.z');"></div>
<img id="img" src\$="[[importPath]]foo.z">
<a id="a" href\$="[[importPath]]foo.z">Foo</a>
<zonk id="import" url\$="[[importPath]]foo.z"></zonk>
<zonk id="resolveUrl" url\$="[[resolveUrl('foo.z')]]"></zonk>
<zonk id="resolveUrlHash" url\$="[[resolveUrl('#foo')]]"></zonk>
<zonk id="resolveUrlAbs" url\$="[[resolveUrl('/foo')]]"></zonk>
<zonk id="root" url\$="[[rootPath]]foo.z"></zonk>
<a id="rel" href\$="[[importPath]]../foo.z?123">Foo</a>
<img id="img" src$="[[importPath]]foo.z">
<a id="a" href$="[[importPath]]foo.z">Foo</a>
<zonk id="import" url$="[[importPath]]foo.z"></zonk>
<zonk id="resolveUrl" url$="[[resolveUrl('foo.z')]]"></zonk>
<zonk id="resolveUrlHash" url$="[[resolveUrl('#foo')]]"></zonk>
<zonk id="resolveUrlAbs" url$="[[resolveUrl('/foo')]]"></zonk>
<zonk id="root" url$="[[rootPath]]foo.z"></zonk>
<a id="rel" href$="[[importPath]]../foo.z?123">Foo</a>
<a id="action" action="foo.z">Foo</a>
<form id="formAction" action\$="[[importPath]]foo.z"></form>
<form id="formAction" action$="[[importPath]]foo.z"></form>
<a id="hash" href="#foo.z">Foo</a>
<a id="absolute" href="/foo.z">Foo</a>
<a id="protocol" href="data:foo.z">Foo</a>
Expand Down