Skip to content
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

backport (dir|base|ext)name from 1.0.0 #15

Merged
merged 2 commits into from
Jun 20, 2018

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Jun 16, 2018

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:

  1. Arguments for those methods are coerced to strings instead of typechecking and throwing.
  2. return '//' was changed to return '/' for the specific case where path starts with two slashes and there are no more path separators in in, e.g. path.dirname('//a').
  3. basename(path, ext) is rewritten using a mix of the backported and the old method — the behavior in the absense of ext is backported without actual changes, and the behavior of ext 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.

ChALkeR and others added 2 commits June 15, 2018 23:26
Backport those methods with compat fixes for arguments.
@goto-bus-stop
Copy link
Member

awesome, thanks. i also added the tests from node.js 0.11 and it looks good there too.

@goto-bus-stop goto-bus-stop merged commit 14ea364 into browserify:v0.x Jun 20, 2018
@goto-bus-stop
Copy link
Member

goto-bus-stop commented Jun 20, 2018

Published as [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants