summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWeijia Wang <381152119@qq.com>2018-01-04 11:55:56 +0800
committerWeijia Wang <381152119@qq.com>2018-01-11 11:11:22 +0800
commit315d1f553de9c1c5cf0ab9ee2623b5420bee8a09 (patch)
treecdbd5c3165838f59e996bbcad8adb40bbffe1736 /test
parent8aec3638cebd338b0ea2a62c3e1469b8e29616d7 (diff)
downloadandroid-node-v8-315d1f553de9c1c5cf0ab9ee2623b5420bee8a09.tar.gz
android-node-v8-315d1f553de9c1c5cf0ab9ee2623b5420bee8a09.tar.bz2
android-node-v8-315d1f553de9c1c5cf0ab9ee2623b5420bee8a09.zip
path: fix path.normalize for relative paths
After slicing, the `lastSegmentLength` should be calculated again, instead of assigning value `j`. PR-URL: https://github.com/nodejs/node/pull/17974 Fixes: https://github.com/nodejs/node/issues/17928 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-path-normalize.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-path-normalize.js b/test/parallel/test-path-normalize.js
index 0820052446..0dd1b8339f 100644
--- a/test/parallel/test-path-normalize.js
+++ b/test/parallel/test-path-normalize.js
@@ -27,6 +27,18 @@ assert.strictEqual(path.win32.normalize('..\\foo..\\..\\..\\bar'),
'..\\..\\bar');
assert.strictEqual(path.win32.normalize('..\\...\\..\\.\\...\\..\\..\\bar'),
'..\\..\\bar');
+assert.strictEqual(path.win32.normalize('../../../foo/../../../bar'),
+ '..\\..\\..\\..\\..\\bar');
+assert.strictEqual(path.win32.normalize('../../../foo/../../../bar/../../'),
+ '..\\..\\..\\..\\..\\..\\');
+assert.strictEqual(
+ path.win32.normalize('../foobar/barfoo/foo/../../../bar/../../'),
+ '..\\..\\'
+);
+assert.strictEqual(
+ path.win32.normalize('../.../../foobar/../../../bar/../../baz'),
+ '..\\..\\..\\..\\baz'
+);
assert.strictEqual(path.posix.normalize('./fixtures///b/../b/c.js'),
'fixtures/b/c.js');
@@ -44,3 +56,15 @@ assert.strictEqual(path.posix.normalize('bar/foo..'), 'bar/foo..');
assert.strictEqual(path.posix.normalize('../foo../../../bar'), '../../bar');
assert.strictEqual(path.posix.normalize('../.../.././.../../../bar'),
'../../bar');
+assert.strictEqual(path.posix.normalize('../../../foo/../../../bar'),
+ '../../../../../bar');
+assert.strictEqual(path.posix.normalize('../../../foo/../../../bar/../../'),
+ '../../../../../../');
+assert.strictEqual(
+ path.posix.normalize('../foobar/barfoo/foo/../../../bar/../../'),
+ '../../'
+);
+assert.strictEqual(
+ path.posix.normalize('../.../../foobar/../../../bar/../../baz'),
+ '../../../../baz'
+);