wishthis/node_modules/is-path-inside/index.js

13 lines
290 B
JavaScript
Raw Normal View History

2022-01-21 08:28:41 +00:00
'use strict';
2023-08-17 09:47:40 +00:00
const path = require('path');
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = (childPath, parentPath) => {
const relation = path.relative(parentPath, childPath);
return Boolean(
relation &&
relation !== '..' &&
!relation.startsWith(`..${path.sep}`) &&
relation !== path.resolve(childPath)
);
2022-01-21 08:28:41 +00:00
};