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.relative behavior inconsistent on case insensitive file system. #18406

Closed
mattrenaud opened this issue Jan 27, 2018 · 2 comments
Closed
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. invalid Issues and PRs that are invalid. path Issues and PRs related to the path subsystem.

Comments

@mattrenaud
Copy link

mattrenaud commented Jan 27, 2018

  • Version: v9.4.0
  • Platform: Darwin matts-air.lan 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
  • Subsystem: path

I have a small demo program to show this issue.

here is the environment:

$ pwd
/Users/matt/test
$ ls -d $(find .)
.		./dir		./dir/file.json	./index.js

Here is index.js:

const sourceFile = "/users/matt/test/dir/file.json";
const destDir = "/Users/matt/test/dest";

const relativePath = require("path").relative(process.cwd(), sourceFile);
const destPath = require("path").join(destDir, relativePath);

console.log(destPath);

when I run I get:

$ node index.js
/Users/users/matt/test/dir/file.json

Notice /Users/users in the path. If I make a change in index.js:

// ...
const sourceFile = "/Users/matt/test/dir/file.json";
// notice capital "Users"
// ...

I get:

matts-air:test matt$ node index.js
/Users/matt/test/dest/dir/file.json 

/Users/matt/test/dest/dir/file.json is correct. So the case is effecting the result and I would expect the result to be the same on a case insensitive file system.

@bnoordhuis bnoordhuis added duplicate Issues and PRs that are duplicates of other issues or PRs. invalid Issues and PRs that are invalid. path Issues and PRs related to the path subsystem. labels Jan 27, 2018
@bnoordhuis
Copy link
Member

This is a duplicate of several other reports. To summarize: it's working as expected, it's not a bug.

The path module doesn't perform I/O, it manipulates strings. It doesn't know about case (in)sensitivity because that is a property of the file system. It can't know about it either because that would rule out the possibility of constructing paths that don't already exist.

@mattrenaud
Copy link
Author

Ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. invalid Issues and PRs that are invalid. path Issues and PRs related to the path subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants