Debian Codegraph @

debian/build_modules/relateurl/lib/util/path.js

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