35a4eded3bc850103e7d90c240242a4c07fd3aa52f8c8190ff88b3ae91d40d0dc234ba4035b44dda48d8bf0d35abac5c58118bf180e8f1ac24c82751c74a9a 576 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. function joinPath(pathArray)
  3. {
  4. if (pathArray.length > 0)
  5. {
  6. return pathArray.join("/") + "/";
  7. }
  8. else
  9. {
  10. return "";
  11. }
  12. }
  13. function resolveDotSegments(pathArray)
  14. {
  15. var pathAbsolute = [];
  16. pathArray.forEach( function(dir)
  17. {
  18. if (dir !== "..")
  19. {
  20. if (dir !== ".")
  21. {
  22. pathAbsolute.push(dir);
  23. }
  24. }
  25. else
  26. {
  27. // Remove parent
  28. if (pathAbsolute.length > 0)
  29. {
  30. pathAbsolute.splice(pathAbsolute.length-1, 1);
  31. }
  32. }
  33. });
  34. return pathAbsolute;
  35. }
  36. module.exports =
  37. {
  38. join: joinPath,
  39. resolveDotSegments: resolveDotSegments
  40. };