(path: string)
| 7 | } |
| 8 | |
| 9 | export function normalizePath(path: string) { |
| 10 | path = normalize(path); |
| 11 | |
| 12 | // MIT https://github.com/sindresorhus/slash/blob/main/license |
| 13 | // Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar |
| 14 | const isExtendedLengthPath = /^\\\\\?\\/.test(path); |
| 15 | const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex |
| 16 | |
| 17 | if (isExtendedLengthPath || hasNonAscii) { |
| 18 | return path; |
| 19 | } |
| 20 | |
| 21 | path = path.replace(/\\/g, '/'); |
| 22 | if (path.endsWith('/')) { |
| 23 | path = path.slice(0, path.length - 1); |
| 24 | } |
| 25 | return path; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Walks the object graph and replaces any DOM Nodes with their string representation. |
no test coverage detected
searching dependent graphs…