From a5be84fe9b6862b9d132f87bcc915285e40432e2 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Fri, 20 Feb 2015 14:00:32 -0800 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig --- lib/url.js | 4 ++-- test/simple/test-url.js | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/url.js b/lib/url.js index e991f6d63f9..d5948e450b1 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 6c807930b58..95f50a23c39 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'],