MCPcopy Index your code
hub / github.com/stenciljs/core / reducePathComponents

Function reducePathComponents

src/utils/path.ts:46–66  ·  view source on GitHub ↗
(components: readonly string[])

Source from the content-addressed store, hash-verified

44const backslashRegExp = /\\/g;
45
46const reducePathComponents = (components: readonly string[]) => {
47 if (!Array.isArray(components) || components.length === 0) {
48 return [];
49 }
50 const reduced = [components[0]];
51 for (let i = 1; i < components.length; i++) {
52 const component = components[i];
53 if (!component) continue;
54 if (component === '.') continue;
55 if (component === '..') {
56 if (reduced.length > 1) {
57 if (reduced[reduced.length - 1] !== '..') {
58 reduced.pop();
59 continue;
60 }
61 } else if (reduced[0]) continue;
62 }
63 reduced.push(component);
64 }
65 return reduced;
66};
67
68const getRootLength = (path: string) => {
69 const rootLength = getEncodedRootLength(path);

Callers 1

normalizePathFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected