Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Use document.location for makeRelPath
Browse files Browse the repository at this point in the history
document.baseURI is a string, does not have properties like .host
  • Loading branch information
dfreedm committed Apr 9, 2014
1 parent ccb7c30 commit 896e245
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function resolveRelativeUrl(baseUrl, url) {
}

function makeDocumentRelPath(url) {
var root = document.baseURI;
var root = document.location;

This comment has been minimized.

Copy link
@goto100

goto100 Apr 25, 2014

this makes the next if statement TRUE, and called makeRelPath, but makeRelPath droped hash and query of origin url, please add them back when makeRelPath

This comment has been minimized.

Copy link
@dfreedm

dfreedm Apr 29, 2014

Author Contributor

This should really be filed as a bug, not a comment on a commit. I've made one here: #19

var u = new URL(url, root);
if (u.host === root.host && u.port === root.port &&
u.protocol === root.protocol) {
Expand Down
27 changes: 27 additions & 0 deletions test/html/url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>URL integration test</title>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../platform.js"></script>
</head>
<body>
<script>
var root = document.location;
var path = '/foo/bar';
var u = new URL(path, root);
chai.assert.equal(u.host, root.host);
chai.assert.equal(u.port, root.port);
chai.assert.equal(u.protocol, root.protocol);
chai.assert.equal(u.pathname, path);
done();
</script>
</body>
</html>
1 change: 1 addition & 0 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ htmlSuite('integration', function() {
});

htmlSuite('URL Loader', function() {
htmlTest('html/url.html');
htmlTest('html/loader-deduplicate.html');
});

Expand Down

0 comments on commit 896e245

Please sign in to comment.