MCPcopy
hub / github.com/1Panel-dev/KubePi / resolve

Function resolve

web/dashboard/src/utils/resolve.js:66–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64 }
65
66 export function resolve() {
67 var resolvedPath = '';
68 var resolvedAbsolute = false;
69 var cwd;
70
71 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
72 var path;
73 if (i >= 0)
74 path = arguments[i];
75 else {
76 if (cwd === undefined)
77 // cwd = process.cwd();
78 path = '';
79 }
80
81 // Skip empty entries
82 if (path.length === 0) {
83 continue;
84 }
85
86 resolvedPath = path + '/' + resolvedPath;
87 resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
88 }
89
90 // At this point the path should be resolved to a full absolute path, but
91 // handle relative paths to be safe (might happen when process.cwd() fails)
92
93 // Normalize the path
94 resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
95
96 if (resolvedAbsolute) {
97 if (resolvedPath.length > 0)
98 return '/' + resolvedPath;
99 else
100 return '/';
101 } else if (resolvedPath.length > 0) {
102 return resolvedPath;
103 } else {
104 return '.';
105 }
106 }

Callers 6

generateRoutesFunction · 0.50
loginFunction · 0.50
isLoginFunction · 0.50
setLanguageFunction · 0.50
getCurrentUserFunction · 0.50
promiseFunction · 0.50

Calls 1

normalizeStringPosixFunction · 0.70

Tested by

no test coverage detected