Skip to content

Commit

Permalink
fix(absoluteTo): return original URI for URI with scheme
Browse files Browse the repository at this point in the history
closes #328 #329
  • Loading branch information
CXuesong authored and rodneyrehm committed Feb 27, 2017
1 parent 0396291 commit 1cc30ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/URI.js
Expand Up @@ -2077,7 +2077,10 @@
base = new URI(base);
}

if (!resolved._parts.protocol) {
if (resolved._parts.protocol) {
// Directly returns even if this._parts.hostname is empty.
return resolved;
} else {
resolved._parts.protocol = base._parts.protocol;
}

Expand Down
10 changes: 10 additions & 0 deletions test/test.js
Expand Up @@ -1342,6 +1342,16 @@
url: 'http://github.com//the_relative_url',
base: 'http://example.com/foo/bar',
result: 'http://github.com//the_relative_url'
}, {
name: 'absolute passthru - file:/// - urljoin (#328)',
url: 'file:///C:/skyclan/snipkit',
base: 'http://example.com/foo/bar',
result: 'file:///C:/skyclan/snipkit'
}, {
name: 'absolute passthru - generic empty-hostname - urljoin (#328)',
url: 'http:///foo',
base: 'http://example.com/foo/bar',
result: 'http:///foo'
}, {
name: 'file paths - urljoin',
url: 'anotherFile',
Expand Down

0 comments on commit 1cc30ee

Please sign in to comment.