MCPcopy
hub / github.com/rollup/rollup / normalizePathSegments

Function normalizePathSegments

browser/src/path.ts:47–61  ·  view source on GitHub ↗
(parts: string[], absolute = false)

Source from the content-addressed store, hash-verified

45}
46
47function normalizePathSegments(parts: string[], absolute = false): string {
48 const normalized: string[] = [];
49 for (const part of parts) {
50 if (part === '..') {
51 if (normalized.length > 0 && normalized[normalized.length - 1] !== '..') {
52 normalized.pop();
53 } else if (!absolute) {
54 normalized.push('..');
55 }
56 } else if (part !== '.' && part !== '') {
57 normalized.push(part);
58 }
59 }
60 return normalized.join('/');
61}
62
63export function relative(from: string, to: string): string {
64 const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);

Callers 2

joinFunction · 0.85
resolveFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…