Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a331b6

Browse filesBrowse files
mscdexsilverwind
authored andcommitted
path: fix verbose relative() output
Fixes: #5383 PR-URL: #5389 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent 5298c81 commit 3a331b6
Copy full SHA for 3a331b6

File tree

Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-1
lines changed
Open diff view settings
Collapse file

‎lib/path.js‎

Copy file name to clipboardExpand all lines: lib/path.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,10 @@ const posix = {
12821282
// We get here if `from` is the exact base path for `to`.
12831283
// For example: from='/foo/bar'; to='/foo/bar/baz'
12841284
return to.slice(i + 2);
1285+
} else if (fromLen > length && from.charCodeAt(i + 1) === 47/*/*/) {
1286+
// We get here if `to` is the exact base path for `from`.
1287+
// For example: from='/foo/bar/baz'; to='/foo/bar'
1288+
lastCommonSep = i;
12851289
}
12861290
break;
12871291
}
Collapse file

‎test/parallel/test-path.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-path.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ const relativeTests = [
481481
['/var/lib', '/var/apache', '../apache'],
482482
['/var/', '/var/lib', 'lib'],
483483
['/', '/var/lib', 'var/lib'],
484-
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json']
484+
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json'],
485+
['/Users/a/web/b/test/mails', '/Users/a/web/b', '../..']
485486
]
486487
]
487488
];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.