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

Function resolveLocalPath

src/path.ts:44–50  ·  view source on GitHub ↗
(source: string, target: string)

Source from the content-addressed store, hash-verified

42 * hashes (e.g., #foo) as non-local paths and likewise returns null.
43 */
44export function resolveLocalPath(source: string, target: string): string | null {
45 if (/^\w+:/.test(target)) return null; // URL
46 if (target.startsWith("#")) return null; // anchor tag
47 const path = resolvePath(source, target);
48 if (path.startsWith("../")) return null; // goes above root
49 return path;
50}
51
52/**
53 * Returns true if the specified specifier refers to a local path, as opposed to

Callers 8

path-test.tsFile · 0.85
maybeFileFunction · 0.85
findAssetsFunction · 0.85
resolveScriptFunction · 0.85
resolveLinkFunction · 0.85
CallExpressionFunction · 0.85
findImportFunction · 0.85
findImportMetaResolveFunction · 0.85

Calls 1

resolvePathFunction · 0.70

Tested by

no test coverage detected