path: fix path.normalize not correctly normalizing relative paths#17974
Closed
starkwang wants to merge 2 commits intonodejs:masterfrom
Closed
path: fix path.normalize not correctly normalizing relative paths#17974starkwang wants to merge 2 commits intonodejs:masterfrom
starkwang wants to merge 2 commits intonodejs:masterfrom
Conversation
Contributor
Author
89d7fa1 to
4acf24e
Compare
Contributor
Author
After slicing, the `lastSegmentLength` should be calculated again, instead of assigning value `j`. Fixes: nodejs#17928
4acf24e to
b1aba4a
Compare
targos
approved these changes
Jan 7, 2018
Member
|
Removed the confirmed-bug label since that one is usually applied to the issues, not the PRs fixing them |
joyeecheung
reviewed
Jan 9, 2018
lib/path.js
Outdated
| } | ||
|
|
||
| function findLastSlashIndex(path, isWin32) { | ||
| var i = path.length - 1; |
Member
There was a problem hiding this comment.
I think the logic here can be simplified to Math.max(path.lastIndexOf(isWin32 ? '\\' : '/'), 0)? Or does iterating over the string with charCodeAt yield any performance benefit?
Contributor
Author
There was a problem hiding this comment.
Here is just inherited from the logic before. I've just removed it and used lastIndexOf.
Contributor
Author
Contributor
Author
|
Landed in 315d1f5 |
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After slicing, the
lastSegmentLengthshould be calculated again.It should be
(res.length - 1 - lastSlashIndex), instead of valuej.Tests for it is also added.
Fixes: #17928
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
path