MCPcopy
hub / github.com/webpack/webpack / getSubPath

Function getSubPath

test/harness/runner/RunnerHelpers.js:9–27  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

7 * @returns {string} subPath
8 */
9const getSubPath = (path) => {
10 let subPath = "";
11 const lastSlash = path.lastIndexOf("/");
12 let firstSlash = path.indexOf("/");
13 if (lastSlash !== -1 && firstSlash !== lastSlash) {
14 if (firstSlash !== -1) {
15 let next = path.indexOf("/", firstSlash + 1);
16 let dir = path.slice(firstSlash + 1, next);
17
18 while (dir === ".") {
19 firstSlash = next;
20 next = path.indexOf("/", firstSlash + 1);
21 dir = path.slice(firstSlash + 1, next);
22 }
23 }
24 subPath = path.slice(firstSlash + 1, lastSlash + 1);
25 }
26 return subPath;
27};
28
29/**
30 * @param {string} path path

Callers 1

_resolveModuleMethod · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected