Skip to content

Commit

Permalink
path: fix verbose relative() output
Browse files Browse the repository at this point in the history
Fixes: #5383
PR-URL: #5389
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • Loading branch information
mscdex authored and rvagg committed Feb 28, 2016
1 parent 378a772 commit 30cec18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,10 @@ const posix = {
// We get here if `from` is the exact base path for `to`.
// For example: from='/foo/bar'; to='/foo/bar/baz'
return to.slice(i + 2);
} else if (fromLen > length && from.charCodeAt(i + 1) === 47/*/*/) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}
break;
}
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ const relativeTests = [
['/var/lib', '/var/apache', '../apache'],
['/var/', '/var/lib', 'lib'],
['/', '/var/lib', 'var/lib'],
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json']
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json'],
['/Users/a/web/b/test/mails', '/Users/a/web/b', '../..']
]
]
];
Expand Down

0 comments on commit 30cec18

Please sign in to comment.