您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

getPaths.js 909B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = function getPaths(path) {
  7. const parts = path.split(/(.*?[\\\/]+)/);
  8. const paths = [path];
  9. const seqments = [parts[parts.length - 1]];
  10. let part = parts[parts.length - 1];
  11. path = path.substr(0, path.length - part.length - 1);
  12. for(let i = parts.length - 2; i > 2; i -= 2) {
  13. paths.push(path);
  14. part = parts[i];
  15. path = path.substr(0, path.length - part.length) || "/";
  16. seqments.push(part.substr(0, part.length - 1));
  17. }
  18. part = parts[1];
  19. seqments.push(part);
  20. paths.push(part);
  21. return {
  22. paths: paths,
  23. seqments: seqments
  24. };
  25. };
  26. module.exports.basename = function basename(path) {
  27. const i = path.lastIndexOf("/"),
  28. j = path.lastIndexOf("\\");
  29. const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
  30. if(p < 0) return null;
  31. const s = path.substr(p + 1);
  32. return s;
  33. };