Skip to content

Commit 407069a

Browse files
committed
test: add known issue test for path parse issue #6229
Refs: #6229 PR-URL: #8293 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 49ef3ae commit 407069a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/6229
3+
4+
require('../common');
5+
const assert = require('assert');
6+
const path = require('path');
7+
8+
{
9+
// The path `/foo/bar` is not the same path as `/foo/bar/`
10+
const parsed1 = path.posix.parse('/foo/bar');
11+
const parsed2 = path.posix.parse('/foo/bar/');
12+
13+
assert.strictEqual(parsed1.root, '/');
14+
assert.strictEqual(parsed1.dir, '/foo');
15+
assert.strictEqual(parsed1.base, 'bar');
16+
17+
assert.strictEqual(parsed2.root, '/');
18+
assert.strictEqual(parsed2.dir, '/foo/bar');
19+
assert.strictEqual(parsed2.base, '');
20+
}
21+
22+
{
23+
// The path `\\foo\\bar` is not the same path as `\\foo\\bar\\`
24+
const parsed1 = path.win32.parse('\\foo\\bar');
25+
const parsed2 = path.win32.parse('\\foo\\bar\\');
26+
27+
assert.strictEqual(parsed1.root, '\\');
28+
assert.strictEqual(parsed1.dir, '\\foo');
29+
assert.strictEqual(parsed1.base, 'bar');
30+
31+
assert.strictEqual(parsed2.root, '\\');
32+
assert.strictEqual(parsed2.dir, '\\foo\\bar');
33+
assert.strictEqual(parsed2.base, '');
34+
}

0 commit comments

Comments
 (0)