(pathEntries: string[])
| 22 | const IS_WEB = |
| 23 | (typeof window !== 'undefined' && typeof window.document !== 'undefined') || |
| 24 | typeof (globalThis as { importScripts?: unknown }).importScripts === 'function'; |
| 25 | interface ResolvedPath { |
| 26 | absolutePath: string; |
| 27 | directoryPaths: string[]; |
| 28 | } |
| 29 | |
| 30 | function normalizePath(pathEntries: string[]): string[] { |
| 31 | const out: string[] = []; |
| 32 | for (const pathEntry of pathEntries) { |
| 33 | if (pathEntry === '..') { |
| 34 | if (out.length) { |
| 35 | // Remove last item |
| 36 | out.pop(); |
| 37 | } else { |
| 38 | // Keep the '..' we went outside our root |
| 39 | out.push(pathEntry); |
| 40 | } |
| 41 | } else if (pathEntry === '.' && !IS_WEB) { |
| 42 | // Omit '.' from the path on Android (1), iOS (2), MacOS (3). On Web (4) keep '.' in the path. |
| 43 | continue; |
| 44 | } else { |
| 45 | out.push(pathEntry); |
| 46 | } |
no test coverage detected