(path: string)
| 149 | // posix version |
| 150 | /** JSDoc */ |
| 151 | export function normalizePath(path: string): string { |
| 152 | const isPathAbsolute = isAbsolute(path); |
| 153 | const trailingSlash = path.slice(-1) === '/'; |
| 154 | |
| 155 | // Normalize the path |
| 156 | let normalizedPath = normalizeArray( |
| 157 | path.split('/').filter(p => !!p), |
| 158 | !isPathAbsolute, |
| 159 | ).join('/'); |
| 160 | |
| 161 | if (!normalizedPath && !isPathAbsolute) { |
| 162 | normalizedPath = '.'; |
| 163 | } |
| 164 | if (normalizedPath && trailingSlash) { |
| 165 | normalizedPath += '/'; |
| 166 | } |
| 167 | |
| 168 | return (isPathAbsolute ? '/' : '') + normalizedPath; |
| 169 | } |
| 170 | |
| 171 | // posix version |
| 172 | /** JSDoc */ |
no test coverage detected