index.js 290 B

123456789101112
  1. 'use strict';
  2. const path = require('path');
  3. module.exports = (childPath, parentPath) => {
  4. const relation = path.relative(parentPath, childPath);
  5. return Boolean(
  6. relation &&
  7. relation !== '..' &&
  8. !relation.startsWith(`..${path.sep}`) &&
  9. relation !== path.resolve(childPath)
  10. );
  11. };