From 519162dbda2e95399213d37418e1444874c58a22 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Aug 2016 21:12:59 -0700 Subject: [PATCH 1/3] test: add known issue test for path parse issue #6229 Refs: https://github.com/nodejs/node/issues/6229 --- test/known_issues/test-path-parse.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/known_issues/test-path-parse.js diff --git a/test/known_issues/test-path-parse.js b/test/known_issues/test-path-parse.js new file mode 100644 index 00000000000000..dfc1f91893a2a4 --- /dev/null +++ b/test/known_issues/test-path-parse.js @@ -0,0 +1,18 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const path = require('path'); + +// Issue: https://github.com/nodejs/node/issues/6229 +// The path `/foo/bar` is not the same path as `/foo/bar/` +const parsed1 = path.parse('/foo/bar'); +const parsed2 = path.parse('/foo/bar/'); + +assert.notDeepStrictEqual(parsed1, parsed2); + +// parsed1 *should* equal: +// {root: '/', dir: '/foo', base: 'bar', ext: '', name: 'bar'} +// +// parsed2 *should* equal: +// {root: '/', dir: '/foo/bar', base: '', ext: '', name: ''} From f60ccf74e25f7a6871d88efff97cd6bdf927ca42 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Aug 2016 21:29:48 -0700 Subject: [PATCH 2/3] Fix nit, rename test --- .../{test-path-parse.js => test-path-parse-6229.js} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/known_issues/{test-path-parse.js => test-path-parse-6229.js} (89%) diff --git a/test/known_issues/test-path-parse.js b/test/known_issues/test-path-parse-6229.js similarity index 89% rename from test/known_issues/test-path-parse.js rename to test/known_issues/test-path-parse-6229.js index dfc1f91893a2a4..a184c8fc9c49f2 100644 --- a/test/known_issues/test-path-parse.js +++ b/test/known_issues/test-path-parse-6229.js @@ -1,10 +1,10 @@ 'use strict'; +// Refs: https://github.com/nodejs/node/issues/6229 require('../common'); const assert = require('assert'); const path = require('path'); -// Issue: https://github.com/nodejs/node/issues/6229 // The path `/foo/bar` is not the same path as `/foo/bar/` const parsed1 = path.parse('/foo/bar'); const parsed2 = path.parse('/foo/bar/'); From 2b41bfeda35feb122858f41df3d85dac40782b1f Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Aug 2016 22:11:12 -0700 Subject: [PATCH 3/3] Address nits --- test/known_issues/test-path-parse-6229.js | 34 +++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/test/known_issues/test-path-parse-6229.js b/test/known_issues/test-path-parse-6229.js index a184c8fc9c49f2..5096a97333159d 100644 --- a/test/known_issues/test-path-parse-6229.js +++ b/test/known_issues/test-path-parse-6229.js @@ -5,14 +5,30 @@ require('../common'); const assert = require('assert'); const path = require('path'); -// The path `/foo/bar` is not the same path as `/foo/bar/` -const parsed1 = path.parse('/foo/bar'); -const parsed2 = path.parse('/foo/bar/'); +{ + // The path `/foo/bar` is not the same path as `/foo/bar/` + const parsed1 = path.posix.parse('/foo/bar'); + const parsed2 = path.posix.parse('/foo/bar/'); -assert.notDeepStrictEqual(parsed1, parsed2); + assert.strictEqual(parsed1.root, '/'); + assert.strictEqual(parsed1.dir, '/foo'); + assert.strictEqual(parsed1.base, 'bar'); -// parsed1 *should* equal: -// {root: '/', dir: '/foo', base: 'bar', ext: '', name: 'bar'} -// -// parsed2 *should* equal: -// {root: '/', dir: '/foo/bar', base: '', ext: '', name: ''} + assert.strictEqual(parsed2.root, '/'); + assert.strictEqual(parsed2.dir, '/foo/bar'); + assert.strictEqual(parsed2.base, ''); +} + +{ + // The path `\\foo\\bar` is not the same path as `\\foo\\bar\\` + const parsed1 = path.win32.parse('\\foo\\bar'); + const parsed2 = path.win32.parse('\\foo\\bar\\'); + + assert.strictEqual(parsed1.root, '\\'); + assert.strictEqual(parsed1.dir, '\\foo'); + assert.strictEqual(parsed1.base, 'bar'); + + assert.strictEqual(parsed2.root, '\\'); + assert.strictEqual(parsed2.dir, '\\foo\\bar'); + assert.strictEqual(parsed2.base, ''); +}