}
result.protocol = relative.protocol;
- if (!relative.host && !hostlessProtocol[relative.protocol]) {
+ if (!relative.host &&
+ !/^file:?$/.test(relative.protocol) &&
+ !hostlessProtocol[relative.protocol]) {
var relPath = (relative.pathname || '').split('/');
while (relPath.length && !(relative.host = relPath.shift()));
if (!relative.host) relative.host = '';
['http://example.com/b//c//d;p?q#blarg',
'http:/a/b/c/d',
'http://example.com/a/b/c/d'],
- ['/foo/bar/baz', '/../etc/passwd', '/etc/passwd']
+ ['/foo/bar/baz', '/../etc/passwd', '/etc/passwd'],
+ ['http://localhost', 'file:///Users/foo', 'file:///Users/foo'],
+ ['http://localhost', 'file://foo/Users', 'file://foo/Users']
];
relativeTests.forEach(function(relativeTest) {
var a = url.resolve(relativeTest[0], relativeTest[1]),