GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — path: remove dead code in favor of unit tests · nodejs/node@4750a2a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • path.js
  • test/parallel
    • test-path-parse-format.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/path.js‎

Copy file name to clipboardExpand all lines: lib/path.js
+1-11Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function win32SplitPath(filename) {
7676
// Separate device+slash from tail
7777
var result = splitDeviceRe.exec(filename),
7878
device = (result[1] || '') + (result[2] || ''),
79-
tail = result[3] || '';
79+
tail = result[3];
8080
// Split the tail into dir, basename and extension
8181
var result2 = splitTailRe.exec(tail),
8282
dir = result2[1],
@@ -386,9 +386,6 @@ win32.parse = function(pathString) {
386386
assertPath(pathString);
387387

388388
var allParts = win32SplitPath(pathString);
389-
if (!allParts || allParts.length !== 4) {
390-
throw new TypeError("Invalid path '" + pathString + "'");
391-
}
392389
return {
393390
root: allParts[0],
394391
dir: allParts[0] + allParts[1].slice(0, -1),
@@ -590,13 +587,6 @@ posix.parse = function(pathString) {
590587
assertPath(pathString);
591588

592589
var allParts = posixSplitPath(pathString);
593-
if (!allParts || allParts.length !== 4) {
594-
throw new TypeError("Invalid path '" + pathString + "'");
595-
}
596-
allParts[1] = allParts[1] || '';
597-
allParts[2] = allParts[2] || '';
598-
allParts[3] = allParts[3] || '';
599-
600590
return {
601591
root: allParts[0],
602592
dir: allParts[0] + allParts[1].slice(0, -1),
Collapse file

‎test/parallel/test-path-parse-format.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-path-parse-format.js
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var winPaths = [
99
'\\foo\\C:',
1010
'file',
1111
'.\\file',
12+
'',
1213

1314
// unc
1415
'\\\\server\\share\\file_path',
@@ -32,7 +33,8 @@ var unixPaths = [
3233
'file',
3334
'.\\file',
3435
'./file',
35-
'C:\\foo'
36+
'C:\\foo',
37+
''
3638
];
3739

3840
var unixSpecialCaseFormatTests = [
@@ -52,8 +54,6 @@ var errors = [
5254
message: /Path must be a string. Received 1/},
5355
{method: 'parse', input: [],
5456
message: /Path must be a string. Received undefined/},
55-
// {method: 'parse', input: [''],
56-
// message: /Invalid path/}, // omitted because it's hard to trigger!
5757
{method: 'format', input: [null],
5858
message: /Parameter 'pathObject' must be an object, not/},
5959
{method: 'format', input: [''],
@@ -93,8 +93,13 @@ function checkErrors(path) {
9393
}
9494

9595
function checkParseFormat(path, paths) {
96-
paths.forEach(function(element, index, array) {
96+
paths.forEach(function(element) {
9797
var output = path.parse(element);
98+
assert.strictEqual(typeof output.root, 'string');
99+
assert.strictEqual(typeof output.dir, 'string');
100+
assert.strictEqual(typeof output.base, 'string');
101+
assert.strictEqual(typeof output.ext, 'string');
102+
assert.strictEqual(typeof output.name, 'string');
98103
assert.strictEqual(path.format(output), element);
99104
assert.strictEqual(output.dir, output.dir ? path.dirname(element) : '');
100105
assert.strictEqual(output.base, path.basename(element));

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.