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 <me@silverwind.io>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Evan Lucas <evanlucas@me.com>
  • Loading branch information
mscdex authored and silverwind committed Feb 27, 2016
1 parent 5298c81 commit 3a331b6
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 @@ -1282,6 +1282,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 3a331b6

Please sign in to comment.