MCPcopy
hub / github.com/foambubble/foam / fromFsPath

Function fromFsPath

packages/foam-core/src/utils/path.ts:198–213  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

196 * given input and authority is undefined except for UNC paths.
197 */
198export function fromFsPath(path: string): [string, string] {
199 let authority: string;
200 if (isUNCShare(path)) {
201 [path, authority] = parseUNCShare(path);
202 } else if (hasDrive(path)) {
203 path = '/' + path[0].toUpperCase() + path.substring(1);
204 } else if (path[0] === '/' && hasDrive(path, 1)) {
205 // POSIX representation of a Windows path: just normalize drive letter case
206 path = '/' + path[1].toUpperCase() + path.substring(2);
207 }
208
209 // Always normalize backslashes to forward slashes (filesystem → POSIX)
210 path = path.replace(/\\/g, '/');
211
212 return [path, authority];
213}
214
215/**
216 * Converts a POSIX path to a filesystem path.

Callers 3

fromVsCodeUriFunction · 0.90
path.test.tsFile · 0.90
resolveUriMethod · 0.90

Calls 4

isUNCShareFunction · 0.85
parseUNCShareFunction · 0.85
hasDriveFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected