Skip to content

Commit

Permalink
Merge pull request #5531 from Polymer/resolve-url
Browse files Browse the repository at this point in the history
Check directly for // in resolveUrl because it isn't a valid URL
  • Loading branch information
aomarks authored May 3, 2019
2 parents 733cf68 + 5537380 commit 969f289
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/utils/resolve-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions test/unit/resolveurl.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 969f289

Please sign in to comment.