domenic / path-is-inside

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

relative paths handling #6

Open plee-nm opened 7 years ago

plee-nm commented 7 years ago

Is it documented that relative paths aren't handled or is this a bug?

const pathIsInside = require("path-is-inside")
const {normalize} = require('path');

const relativePath = '/a/b/c/../../';
const inside = '/a/b';

console.log(`checking to see if ${normalize(relativePath)} is inside of ${inside}`);

console.log(pathIsInside(relativePath, inside));
console.log(pathIsInside('/a/', inside));

https://runkit.com/plee-nm/runkit-npm-path-is-inside

domenic commented 7 years ago

It should be documented. Pull request welcome.

digitalica commented 5 years ago

i think it would make more sense to handle it, so path.normalize() the paths before comparison. As then the 'isInside' question would be answered more correctly... This would be a breaking (the functionality, not the docs ;-) ) change though.