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 repetitive conditional operator in `posix.resolve` · nodejs/node@3a682cc

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
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,8 @@ const posix = {
11641164
let resolvedPath = '';
11651165
let resolvedAbsolute = false;
11661166

1167-
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1168-
const path = i >= 0 ? args[i] : posixCwd();
1167+
for (let i = args.length - 1; i >= 0 && !resolvedAbsolute; i--) {
1168+
const path = args[i];
11691169
validateString(path, `paths[${i}]`);
11701170

11711171
// Skip empty entries
@@ -1178,6 +1178,13 @@ const posix = {
11781178
StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH;
11791179
}
11801180

1181+
if (!resolvedAbsolute) {
1182+
const cwd = posixCwd();
1183+
resolvedPath = `${cwd}/${resolvedPath}`;
1184+
resolvedAbsolute =
1185+
StringPrototypeCharCodeAt(cwd, 0) === CHAR_FORWARD_SLASH;
1186+
}
1187+
11811188
// At this point the path should be resolved to a full absolute path, but
11821189
// handle relative paths to be safe (might happen when process.cwd() fails)
11831190

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.