bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
48 lines (34 loc) • 1.36 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _stripTrailingChar() {
const data = _interopRequireDefault(require("./string/strip-trailing-char"));
_stripTrailingChar = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../constants");
_constants = function () {
return data;
};
return data;
}
module.exports = function (thePath, potentialParent) {
// For inside-directory checking, we want to allow trailing slashes, so normalize.
thePath = (0, _stripTrailingChar().default)(thePath, path().sep);
potentialParent = (0, _stripTrailingChar().default)(potentialParent, path().sep); // Node treats only Windows as case-insensitive in its path module; we follow those conventions.
if (process.platform === 'win32') {
thePath = thePath.toLowerCase();
potentialParent = potentialParent.toLowerCase();
}
return thePath.lastIndexOf(potentialParent, 0) === 0 && (thePath[potentialParent.length] === _constants().DEFAULT_SEPARATOR || thePath[potentialParent.length] === undefined);
};
;