3 var path = require("path");
5 module.exports = function (thePath, potentialParent) {
6 // For inside-directory checking, we want to allow trailing slashes, so normalize.
7 thePath = stripTrailingSep(thePath);
8 potentialParent = stripTrailingSep(potentialParent);
10 // Node treats only Windows as case-insensitive in its path module; we follow those conventions.
11 if (process.platform === "win32") {
12 thePath = thePath.toLowerCase();
13 potentialParent = potentialParent.toLowerCase();
16 return thePath.indexOf(potentialParent) === 0;
19 function stripTrailingSep(thePath) {
20 if (thePath[thePath.length - 1] === path.sep) {
21 return thePath.slice(0, -1);