-
Notifications
You must be signed in to change notification settings - Fork 366
Handle empty root in util.relative #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hmm, perhaps empty strings should be treated as |
test/source-map/test-util.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor nitpick: Change rootone into root/one. rootone.js is used in the above line just to make sure that libUtil.relative doesn’t think that it should strip /the/root (since both arguments start with that string), because that would be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks.
Are you proposing that both
Agreed. The test I added for the empty string would break without this change too. |
Re mozilla#128, an empty root passed to util.relative should return 'aPath' as-is. This avoids stripping the leading '/' off of absolute paths. This treats root paths of '' and '.' the same. Root path of '/' will strip the leading '/' from any path.
|
@lydell Applied the suggested changes. The only thing I'm not sure about is this test case. You might argue that it should behave like As implemented, using |
Yes, definitely. Reviewing changes now... |
No, that looks good as-is. |
Handle empty root in util.relative
|
Thanks for the pull request! |
|
Thanks for the quick turnaround! |
|
@fitzgen Could you publish it as 0.1.38? It passes all webpack tests now... |
|
@sokra done. |
Re #128, an empty root passed to util.relative should return
aPathas-is. This avoids stripping the leading/off of absolute file paths.Since we don't know whether the empty string is a URL or a file path, we cannot make an assumption either way and should return the path unmodified.
See webpack/core#5 for context around this fix. Specifically, webpack/core#5 (comment) and webpack/core#5 (comment).