Skip to content

path.relative behavior inconsistent on case insensitive file system. #18406

Closed
@mattrenaud

Description

@mattrenaud
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.invalidIssues and PRs that are invalid.pathIssues and PRs related to the path subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions