MCPcopy Create free account
hub / github.com/observablehq/framework / resolvePath

Function resolvePath

src/path.ts:33–37  ·  view source on GitHub ↗
(root: string, source: string, target?: string)

Source from the content-addressed store, hash-verified

31export function resolvePath(source: string, target: string): string;
32export function resolvePath(root: string, source: string, target: string): string;
33export function resolvePath(root: string, source: string, target?: string): string {
34 if (target === undefined) (target = source), (source = root), (root = ".");
35 const path = join(root, target === "" ? source : target.startsWith("/") ? "." : dirname(source), target);
36 return path.startsWith("../") ? path : join("/", path);
37}
38
39/**
40 * Like resolvePath, except returns null if the specified target goes outside

Callers 2

resolveLocalPathFunction · 0.70
resolveRelativePathFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected