(path: string)
| 27 | * - Remove trailing slash (except root) |
| 28 | */ |
| 29 | export const normalizePath = (path: string): string => { |
| 30 | let normalized = path.replace(/\/+/g, '/'); |
| 31 | if (!normalized.startsWith('/')) { |
| 32 | normalized = '/' + normalized; |
| 33 | } |
| 34 | if (normalized.length > 1 && normalized.endsWith('/')) { |
| 35 | normalized = normalized.slice(0, -1); |
| 36 | } |
| 37 | return normalized; |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * Extract directory path from full path (without leading slash) |
no outgoing calls
no test coverage detected