(input: string)
| 103 | |
| 104 | export function createPathHelpers(scope: () => string) { |
| 105 | const normalize = (input: string) => { |
| 106 | const root = scope() |
| 107 | |
| 108 | let path = unquoteGitPath(decodeFilePath(stripQueryAndHash(stripFileProtocol(input)))) |
| 109 | |
| 110 | // Separator-agnostic prefix stripping for Cygwin/native Windows compatibility |
| 111 | // Only case-insensitive on Windows (drive letter or UNC paths) |
| 112 | const windows = /^[A-Za-z]:/.test(root) || root.startsWith("\\\\") |
| 113 | const canonRoot = windows ? root.replace(/\\/g, "/").toLowerCase() : root.replace(/\\/g, "/") |
| 114 | const canonPath = windows ? path.replace(/\\/g, "/").toLowerCase() : path.replace(/\\/g, "/") |
| 115 | if ( |
| 116 | canonPath.startsWith(canonRoot) && |
| 117 | (canonRoot.endsWith("/") || canonPath === canonRoot || canonPath[canonRoot.length] === "/") |
| 118 | ) { |
| 119 | // Slice from original path to preserve native separators |
| 120 | path = path.slice(root.length) |
| 121 | } |
| 122 | |
| 123 | if (path.startsWith("./") || path.startsWith(".\\")) { |
| 124 | path = path.slice(2) |
| 125 | } |
| 126 | |
| 127 | if (path.startsWith("/") || path.startsWith("\\")) { |
| 128 | path = path.slice(1) |
| 129 | } |
| 130 | return path |
| 131 | } |
| 132 | |
| 133 | const tab = (input: string) => { |
| 134 | const path = normalize(input) |
no test coverage detected