backport (dir|base|ext)name from 1.0.0 #15
Merged
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.
Backport those methods with compat fixes for arguments to v0.0.x.
.dirname
,.basename
, and.extname
methods are extracted from Node.js v8.11.1 transplited with Babel, (the same as was used for v1.0.0), but with several backwards-compat fixes.Those fixes were:
return '//'
was changed toreturn '/'
for the specific case wherepath
starts with two slashes and there are no more path separators in in, e.g.path.dirname('//a')
.basename(path, ext)
is rewritten using a mix of the backported and the old method — the behavior in the absense ofext
is backported without actual changes, and the behavior ofext
is kept as it was before. See Inconsistent behavior of path.basename(path, ext) nodejs/node#21358 for more info on what it affects.I believe that this patch is strictly backwards-compatible with
v0.0.0
, but faster.I used https://gist.github.com/ChALkeR/3e73885c93766ba5417f3fc4891a7e15 to verify the compatibility — though it's not a complete check, it bruteforces some strings and checks if the output is equal to the old version. That was used to find inconsistencies behind two of three fixes above.
Releasing this as
0.0.1
should match with~0.0.0
specifier and propagate the update faster.