(path: string)
| 193 | } |
| 194 | |
| 195 | function normalizePath(path: string): string { |
| 196 | if (!path.startsWith("/")) path = "/" + path; |
| 197 | const parts = path.split("/"); |
| 198 | const resolved: string[] = []; |
| 199 | for (const part of parts) { |
| 200 | if (part === "" || part === ".") continue; |
| 201 | if (part === "..") { |
| 202 | resolved.pop(); |
| 203 | } else { |
| 204 | resolved.push(part); |
| 205 | } |
| 206 | } |
| 207 | return "/" + resolved.join("/"); |
| 208 | } |
| 209 | |
| 210 | function dirname(path: string): string { |
| 211 | const normalized = normalizePath(path); |
no test coverage detected