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

path.format root and dir don't behave as naturally expected and effect path.parse #5043

Closed
ganna-shmatova opened this issue Feb 2, 2016 · 2 comments
Labels
path Issues and PRs related to the path subsystem. windows Issues and PRs related to the Windows platform.

Comments

@ganna-shmatova
Copy link

I've been using these to try to normalize odd user path entries, ei (\\programdata or c:\\programdata would both change to c:\\programdata on all windows systems)

Similar issue as this: #1999

But the issue fields are root and dir. Dir contains root, but wouldn't it make sense for it to omit root?
Furthermore this doesn't work, probably a result of the ambiguity in ^:

var testPath = path.parse(__dirname);
console.log(testPath);
testPath.root = "D:\\";
console.log(testPath);
var newPath = path.format(testPath);
console.log(newPath);

output:
image

@mscdex mscdex added windows Issues and PRs related to the Windows platform. path Issues and PRs related to the path subsystem. labels Feb 2, 2016
@nwoltman
Copy link
Contributor

nwoltman commented Feb 9, 2016

path.format is behaving as expected here because the root value should always be the same as the start of the dir value. It makes sense for dir to contain the root because you want dir to be the absolute path to the directory of the path being parsed. dir without the root would be a pretty useless value in most cases (perhaps not in your case, but for the majority of users).

I think the solution outlined in #1999 would be helpful in solving your problem, but as I suggested there, it's probably best suited for user-land.

@Fishrock123
Copy link
Contributor

Sounds like this was solved, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
path Issues and PRs related to the path subsystem. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

4 participants