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: refactor path joining logic for clarity and performance · nodejs/node@f667215

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • path.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
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ArrayPrototypeIncludes,
2626
ArrayPrototypeJoin,
27+
ArrayPrototypePush,
2728
ArrayPrototypeSlice,
2829
FunctionPrototypeBind,
2930
StringPrototypeCharCodeAt,
@@ -506,22 +507,21 @@ const win32 = {
506507
if (args.length === 0)
507508
return '.';
508509

509-
let joined;
510-
let firstPart;
510+
const path = [];
511511
for (let i = 0; i < args.length; ++i) {
512512
const arg = args[i];
513513
validateString(arg, 'path');
514514
if (arg.length > 0) {
515-
if (joined === undefined)
516-
joined = firstPart = arg;
517-
else
518-
joined += `\\${arg}`;
515+
ArrayPrototypePush(path, arg);
519516
}
520517
}
521518

522-
if (joined === undefined)
519+
if (path.length === 0)
523520
return '.';
524521

522+
const firstPart = path[0];
523+
let joined = ArrayPrototypeJoin(path, '\\');
524+
525525
// Make sure that the joined path doesn't start with two slashes, because
526526
// normalize() will mistake it for a UNC path then.
527527
//

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.