-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
lib: fix basename comparison on windows #4669
Conversation
This change assumes that |
Also, I'm not sure that the |
9a720a4
to
4febedf
Compare
Thanks @mscdex, I've address those comments |
test/parallel/test-path.js
Outdated
@@ -406,6 +406,15 @@ assert.equal(path.win32.delimiter, ';'); | |||
// posix | |||
assert.equal(path.posix.delimiter, ':'); | |||
|
|||
// ensure ext comparison is case-insensitive on windows | |||
if (common.isWindows) { |
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.
I think this conditional can be dropped as well, since path.win32
would be available on all platforms and is the same implementations that would be used on real Windows.
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.
Thanks @mscdex, I've changed this
4febedf
to
b62b2b0
Compare
@@ -340,11 +340,20 @@ win32.basename = function(path, ext) { | |||
if (ext !== undefined && typeof ext !== 'string') | |||
throw new TypeError('"ext" argument must be a string'); | |||
|
|||
var f = win32SplitPath(path)[2]; | |||
// TODO: make this comparison case-insensitive on windows? | |||
if (ext && f.substr(-1 * ext.length) === ext) { |
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.
Would if (ext && f.substr(-1 * ext.length).toLowerCase() === ext.toLowerCase()) {
have been enough to address the original comment?
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.
It would, but you were concerned with readability in a previous comment, that would work, but would kill readability
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.
For readability, it could be: if (ext && f.toLowerCase().endsWith(ext.toLowerCase())) {
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.
That is much more elegant and witty.
I'll push a fix soon, thanks @cjihrig.
b62b2b0
to
1d05b89
Compare
/poke Would this be a semver-minor change? |
It's a backwards incompatible change so semver-major, I'll add the tag. Apropos It's currently implemented using the unibrow library but I know that the V8 team has plans to swap it out for ICU because unibrow lags behind the Unicode spec. To wit, V8's test suite has a number of regression tests for In other words, this may not be an entirely risk-free change. |
/poke |
/cc @bnoordhuis @mscdex @orangemocha ... any thoughts on this one? |
No objections to doing case-insensitive matching, but this function has undergone substantial changes (and the todo was removed) with b212be0. Could you please rework your changes over the current master branch? |
@tflanagan .. ping |
7da4fd4
to
c7066fb
Compare
@tflanagan ping |
@tflanagan Same question here: Any chance you can do a rebase? If not, I or someone else can try to take it on, but it would be awesome to get this landed and it would be great to see you back in action. (But I totally get it if you're busy with other stuff or your interests have gone elsewhere!) |
c133999
to
83c7a88
Compare
Closing given the lack of forward progress on this. |
Fixes TODO in lib/path.js ref'd here #4642