You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
439B

  1. 'use strict';
  2. const path = require('path');
  3. module.exports = (childPath, parentPath) => {
  4. childPath = path.resolve(childPath);
  5. parentPath = path.resolve(parentPath);
  6. if (process.platform === 'win32') {
  7. childPath = childPath.toLowerCase();
  8. parentPath = parentPath.toLowerCase();
  9. }
  10. if (childPath === parentPath) {
  11. return false;
  12. }
  13. childPath += path.sep;
  14. parentPath += path.sep;
  15. return childPath.startsWith(parentPath);
  16. };