MCPcopy Create free account
hub / github.com/nodejs/node / combinePaths

Function combinePaths

test/fixtures/snapshot/typescript.js:7922–7942  ·  view source on GitHub ↗

* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. * * ```ts * // Non-rooted * combinePaths("path", "to", "file.ext") === "path/to/file.ext" * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file

(path)

Source from the content-addressed store, hash-verified

7920 * ```
7921 */
7922 function combinePaths(path) {
7923 var paths = [];
7924 for (var _i = 1; _i < arguments.length; _i++) {
7925 paths[_i - 1] = arguments[_i];
7926 }
7927 if (path)
7928 path = normalizeSlashes(path);
7929 for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7930 var relativePath = paths_1[_a];
7931 if (!relativePath)
7932 continue;
7933 relativePath = normalizeSlashes(relativePath);
7934 if (!path || getRootLength(relativePath) !== 0) {
7935 path = relativePath;
7936 }
7937 else {
7938 path = ensureTrailingDirectorySeparator(path) + relativePath;
7939 }
7940 }
7941 return path;
7942 }
7943 ts.combinePaths = combinePaths;
7944 /**
7945 * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any

Callers 3

getPathComponentsFunction · 0.85
comparePathsFunction · 0.85
containsPathFunction · 0.85

Calls 3

normalizeSlashesFunction · 0.85
getRootLengthFunction · 0.85

Tested by

no test coverage detected