(path: string)
| 1569 | } |
| 1570 | |
| 1571 | function normalizePath(path: string): string { |
| 1572 | if (!path.startsWith("/")) path = "/" + path; |
| 1573 | const parts = path.split("/"); |
| 1574 | const resolved: string[] = []; |
| 1575 | for (const part of parts) { |
| 1576 | if (part === "" || part === ".") continue; |
| 1577 | if (part === "..") { |
| 1578 | resolved.pop(); |
| 1579 | } else { |
| 1580 | resolved.push(part); |
| 1581 | } |
| 1582 | } |
| 1583 | const result = "/" + resolved.join("/"); |
| 1584 | if (result.length > MAX_PATH_LENGTH) { |
| 1585 | throw new Error(`ENAMETOOLONG: path exceeds ${MAX_PATH_LENGTH} characters`); |
| 1586 | } |
| 1587 | return result; |
| 1588 | } |
| 1589 | |
| 1590 | function getParent(path: string): string { |
| 1591 | const normalized = normalizePath(path); |
no test coverage detected