summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Gilli <julien.gilli@joyent.com>2015-02-20 14:00:32 -0800
committerJulien Gilli <julien.gilli@joyent.com>2015-03-06 12:44:06 -0800
commita5be84fe9b6862b9d132f87bcc915285e40432e2 (patch)
tree3ca98bd510132759d6556142a898b7b0a3819eab
parentdcff5d565c000904cabf48c627534a779a40527a (diff)
downloadnode-a5be84fe9b6862b9d132f87bcc915285e40432e2.tar.gz
url: revert reslove urls with . and ..
This reverts commit ad0684807c474db5cda7d28592e34e19910eb7ab. Initially, this bug fix targeted master, and I pushed to have it included in v0.10. In retrospect, I'm not sure it should have made into v0.10 as it seems it could break a lot of existing working code. In my opinion, this change is still a bug fix, and it is not backward incompatible per se. However, I'm not sure that taking the risk to break a lot of users with a new 0.10.x release that would include this fix is reasonable, especially now that 0.10.x releases are entering maintenance mode. PR-URL: https://github.com/joyent/node/pull/9257 Reviewed-by: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--lib/url.js4
-rw-r--r--test/simple/test-url.js8
2 files changed, 2 insertions, 10 deletions
diff --git a/lib/url.js b/lib/url.js
index e991f6d63..d5948e450 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -600,8 +600,8 @@ Url.prototype.resolveObject = function(relative) {
// then it must NOT get a trailing slash.
var last = srcPath.slice(-1)[0];
var hasTrailingSlash = (
- (result.host || relative.host || srcPath.length > 1) &&
- (last === '.' || last === '..') || last === '');
+ (result.host || relative.host) && (last === '.' || last === '..') ||
+ last === '');
// strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0
diff --git a/test/simple/test-url.js b/test/simple/test-url.js
index 6c807930b..95f50a23c 100644
--- a/test/simple/test-url.js
+++ b/test/simple/test-url.js
@@ -1087,14 +1087,6 @@ var relativeTests = [
['/foo/bar/baz/', 'quux/baz', '/foo/bar/baz/quux/baz'],
['/foo/bar/baz', '../../../../../../../../quux/baz', '/quux/baz'],
['/foo/bar/baz', '../../../../../../../quux/baz', '/quux/baz'],
- ['/foo', '.', '/'],
- ['/foo', '..', '/'],
- ['/foo/', '.', '/foo/'],
- ['/foo/', '..', '/'],
- ['/foo/bar', '.', '/foo/'],
- ['/foo/bar', '..', '/'],
- ['/foo/bar/', '.', '/foo/bar/'],
- ['/foo/bar/', '..', '/foo/'],
['foo/bar', '../../../baz', '../../baz'],
['foo/bar/', '../../../baz', '../baz'],
['http://example.com/b//c//d;p?q#blarg', 'https:#hash2', 'https:///#hash2'],