path: make format() consistent and more functional#2408
Closed
nwoltman wants to merge 1 commit intonodejs:masterfrom
Closed
path: make format() consistent and more functional#2408nwoltman wants to merge 1 commit intonodejs:masterfrom
nwoltman wants to merge 1 commit intonodejs:masterfrom
Conversation
Contributor
|
Sorry for the delay. Starting this off with a CI: https://ci.nodejs.org/job/node-test-pull-request/257/ |
Contributor
Author
|
Tests look good. |
Contributor
Author
|
Bump |
Member
|
@nodejs/ctc ... any thoughts on this one? |
Contributor
Author
|
Resolved conflicts |
Member
|
this seems reasonable to me, would be good to get @nodejs/platform-windows involved |
Member
|
LGTM CI (with rebase to master): https://ci.nodejs.org/job/node-test-pull-request/775/ |
Member
There was a problem hiding this comment.
Since we're in here making changes anyway, the require decls and these top level decls could be change to const now
Member
|
One comment, otherwise LGTM |
Make the win32 and posix versions of path.format() consistent in when they add a directory separator between the dir and base parts of the path (always add it unless the dir part is the same as the root). Also, path.format() is now more functional in that it uses the name and ext parts of the path if the base part is left out and it uses the root part if the dir part is left out.
Contributor
Author
|
Changed top level |
joaocgreis
pushed a commit
to JaneaSystems/node
that referenced
this pull request
Nov 27, 2015
Make the win32 and posix versions of path.format() consistent in when they add a directory separator between the dir and base parts of the path (always add it unless the dir part is the same as the root). Also, path.format() is now more functional in that it uses the name and ext parts of the path if the base part is left out and it uses the root part if the dir part is left out. Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: nodejs#2408
Member
|
Landed in d1000b4 . @woollybogger thank you for the code and for your patience! |
Closed
scovetta
pushed a commit
to scovetta/node
that referenced
this pull request
Apr 2, 2016
Make the win32 and posix versions of path.format() consistent in when they add a directory separator between the dir and base parts of the path (always add it unless the dir part is the same as the root). Also, path.format() is now more functional in that it uses the name and ext parts of the path if the base part is left out and it uses the root part if the dir part is left out. Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: nodejs#2408
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR makes the
win32andposixversions ofpath.format()consistent in when they add a directory separator between the dir and base parts of the path (always add it unless thedirpart is the same as therootpart). This fixes the following inconsistencies:path.win32.format({dir: 'folder\\', base: 'file.txt'})'folder\\file.txt''folder\\\\file.txt'posix.format({dir: 'folder/', base: 'file.txt'})'folder//file.txt'win32.format({root: 'C:\\', dir: 'C:\\'})'C:\\'win32.format({root: '\\\\unc\\path\\', dir: '\\\\unc\\path\\'})'\\\\unc\\path\\'posix.format({root: '/', dir: '/'})'//''/'This fixes bugs in
path.format()andpath.parse()being mirrors of each other (now they truly are mirrors for bothwin32andposix).Also,
path.format()is now more functional in that it uses thenameandextparts of the path if thebasepart is left out, and it uses therootpart if thedirpart is left out. I added an example to the docs to show the new functionality.I also removed the check for
pathObject.rootto be a string, partially because before this commit,pathObject.rootwasn't being used for anything in thepath.format()function, and also because if that part gets checked then all of the parts should get checked.Alternatively, the code could check that all of the path parts in the
pathObjectare strings, in which case it could just go back to using only thedirandbaseparts (essentially expecting the input to only come frompath.parse()).The discussion for this originated here.