MCPcopy Create free account
hub / github.com/agegr/pi-web / getRelativeFilePath

Function getRelativeFilePath

lib/file-paths.ts:30–39  ·  view source on GitHub ↗
(filePath: string, cwd?: string)

Source from the content-addressed store, hash-verified

28}
29
30export function getRelativeFilePath(filePath: string, cwd?: string): string {
31 if (!cwd) return filePath;
32
33 const normalizedFile = normalizeFilePathSlashes(filePath);
34 const normalizedCwd = normalizeFilePathSlashes(cwd).replace(/\/$/, "");
35 if (normalizedFile.startsWith(normalizedCwd + "/")) {
36 return normalizedFile.slice(normalizedCwd.length + 1);
37 }
38 return filePath;
39}
40
41export function joinFilePath(parent: string, child: string): string {
42 return `${normalizeFilePathSlashes(parent).replace(/\/$/, "")}/${child}`;

Callers 6

ImageViewerFunction · 0.90
AudioViewerFunction · 0.90
DocumentViewerFunction · 0.90
TextFileViewerFunction · 0.90
TreeNodeFunction · 0.90
FileExplorer.tsxFile · 0.90

Calls 1

normalizeFilePathSlashesFunction · 0.70

Tested by

no test coverage detected