Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

path: fix bugs related to paths with trailing slashes #4536

Closed
wants to merge 1 commit into from

Conversation

AndreasMadsen
Copy link
Member

Fix issue #4520

After look more closely at the splitPath code path.basename wasn't the only method there was (or would be) wrong.

  • path.extname('/file.ext/')returned '' (empty string). It now returns .ext
  • path.dirname('////') returned //, it now returns '/'.
  • path.basename('/file.ext/') returned file.ext/, it now returns file.ext.

This should be tested on windows as well, I have a license but I have never managed to compile node on windows properly. Could someone else test this?

Note: originally I had hoped to simply fix the splitPathRe regexp, but matching a not-fixed number of / at multiply positions did quickly become complicated.

/cc @bnoordhuis

@isaacs
Copy link

isaacs commented Jan 11, 2013

Landed on bb1c039. Thanks!

@isaacs isaacs closed this Jan 11, 2013
@piscisaureus
Copy link

This is so obviously not correct, I can't even imagine how it passed review :-(

I will revert this tomorrow.

@isaacs
Copy link

isaacs commented Jan 11, 2013

@piscisaureus You mean not correct on windows? It seems to do the right thing on Unix.

@isaacs isaacs reopened this Jan 11, 2013
@AndreasMadsen
Copy link
Member Author

@piscisaureus can you tell if windows in this case can be correctly simulated by settings isWindows = true?

piscisaureus added a commit to piscisaureus/node that referenced this pull request Jan 11, 2013
@AndreasMadsen
Copy link
Member Author

@piscisaureus thanks, very neat

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

Successfully merging this pull request may close these issues.

3 participants