domenic / path-is-inside

Tests whether one path is inside another path
Other
41 stars 4 forks source link

Path isn't inside if it's the same #2

Closed sindresorhus closed 10 years ago

sindresorhus commented 10 years ago

When both paths are identical it returns true, but that is kinda misleading as it's supposed to tell whether the path is inside another one.

Testcase:

console.log(pathIsInside(process.cwd(), process.cwd()));
//=> true

Should return false.

Sidenote: you should path.resolve(thePath) so I the consumer doesn't have to do it when passing relative paths.

domenic commented 10 years ago

It's certainly debatable, but for the purposes of this module, a path is inside itself.

I'd accept a PR for a pathIsInside.exclusive that returns false in that case.

Sidenote: you should path.resolve(thePath) so I the consumer doesn't have to do it when passing relative paths.

No; this is the user's responsibility.

sindresorhus commented 10 years ago

It's certainly debatable, but for the purposes of this module, a path is inside itself.

At least point out the behaviour in the usage example. It was a surprise to me.

No; this is the user's responsibility.

That's inconsistent with any Node core method which which accepts a path, which can be relative.

domenic commented 10 years ago

At least point out the behaviour in the usage example. It was a surprise to me.

Done.

That's inconsistent with any Node core method which which accepts a path, which can be relative.

It's consistent with all methods in path except for path.relative.