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
fix(shouldIgnore): filename normalization should be platform sensitive #4631
Conversation
shouldIgnore normalizes the path of the filename prior to running any "only" regexes or functions. The normalization uses "slash", which has some undesirable special cases for non-ASCII characters and longer paths. Changing the normalization behavior to always replace path separators. There is no real need to add additional tests, because the tests are not run in an environment where path.sep !== '/'.
Current coverage is 88.78% (diff: 100%)@@ master #4631 diff @@
==========================================
Files 195 195
Lines 13773 13822 +49
Methods 1425 1434 +9
Messages 0 0
Branches 3171 3196 +25
==========================================
+ Hits 12223 12272 +49
Misses 1550 1550
Partials 0 0
|
Any feedback on this? |
Don't know much about what it's doing there - would there be other places we want to do this? Also this would be removing |
@hzoo there may be other cases. In this specific case it has an impact on the babel register behavior. If I register babel to transform paths matching |
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.
This looks overall valid to me, as we do not care about long paths and non-ascii characters in the filename, as everything we want to do here is simply doing string comparison with the strings and not use any path
functionality.
@@ -116,7 +116,9 @@ export function shouldIgnore( | |||
ignore: Array<RegExp | Function> = [], | |||
only?: Array<RegExp | Function>, | |||
): boolean { | |||
filename = slash(filename); | |||
if (path.sep !== "/") { |
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.
We probably can safely remove this check, as slash()
is also always doing the replacement, not matter what path.sep
is set to.
https://github.com/sindresorhus/slash/blob/master/index.js
Thanks @danez, removed the conditional as you suggested. |
babel#4631) * fix(shouldIgnore): filename normalization should be platform sensitive shouldIgnore normalizes the path of the filename prior to running any "only" regexes or functions. The normalization uses "slash", which has some undesirable special cases for non-ASCII characters and longer paths. Changing the normalization behavior to always replace path separators. There is no real need to add additional tests, because the tests are not run in an environment where path.sep !== '/'. * Minor style fix to use double quotes. * Remove conditional for regex replace to keep consistent behavior. * whitespace [skip ci]
shouldIgnore normalizes the path of the filename prior to running any "only" regexes or functions. The normalization uses "slash", which has some undesirable special cases for non-ASCII characters and longer paths. Changing the normalization behavior to always replace path separators.
There is no real need to add additional tests, because the tests are not run in an environment where path.sep !== '/' anyway.