(...paths: string[])
| 1 | export function joinPath(...paths: string[]): string { |
| 2 | let result = ""; |
| 3 | |
| 4 | for (const path of paths) { |
| 5 | if (!path) { |
| 6 | continue; |
| 7 | } |
| 8 | |
| 9 | let start = 0; |
| 10 | |
| 11 | for (let i = 0; i <= path.length; i++) { |
| 12 | if (i !== path.length && path[i] !== "/") { |
| 13 | continue; |
| 14 | } |
| 15 | |
| 16 | if (i > start) { |
| 17 | result += `/${path.slice(start, i)}`; |
| 18 | } |
| 19 | |
| 20 | start = i + 1; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return result; |
| 25 | } |
no test coverage detected