MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / stripWin32NamespacePrefix

Function stripWin32NamespacePrefix

src/utils.ts:263–270  ·  view source on GitHub ↗

* The plain spelling of a Win32 namespace path: `\\?\C:\x` and `\\.\C:\x` are * `C:\x`, and `\\?\UNC\host\share` is `\\host\share`. `path.resolve` keeps the * prefix, so a string comparison would never see the folder behind it. Other * namespace paths (a `\\?\Volume{…}\` name, a device) are retur

(p: string)

Source from the content-addressed store, hash-verified

261 * the real path the caller also checks names their folder.
262 */
263function stripWin32NamespacePrefix(p: string): string {
264 if (process.platform !== 'win32') return p;
265 const prefix = /^[\\/]{2}[?.][\\/](UNC[\\/])?/i.exec(p);
266 if (!prefix) return p;
267 const rest = p.slice(prefix[0].length);
268 if (prefix[1]) return `\\\\${rest}`;
269 return /^[a-z]:[\\/]/i.test(rest) ? rest : p;
270}
271
272/**
273 * The folder a path really names: links (symlinks, junctions, a `subst` drive)

Callers 1

Calls 1

execMethod · 0.65

Tested by

no test coverage detected