MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / rewriteAssetPath

Function rewriteAssetPath

packages/parsers/src/rewriteSubCompPaths.ts:44–52  ·  view source on GitHub ↗
(compSrcPath: string, relativePath: string)

Source from the content-addressed store, hash-verified

42 * the original path if no rewriting is needed.
43 */
44export function rewriteAssetPath(compSrcPath: string, relativePath: string): string {
45 if (isAbsoluteOrSpecial(relativePath)) return relativePath;
46 if (!needsRewrite(relativePath)) return relativePath;
47 const compDir = dirname(compSrcPath);
48 if (!compDir || compDir === ".") return relativePath;
49 const resolved = join(compDir, relativePath);
50 const normalized = resolve("/", resolved).slice(1);
51 return normalized;
52}
53
54/**
55 * Rewrite all relative `src` and `href` attributes on elements within a

Callers 6

lintAudioSrcNotFoundFunction · 0.85
lintMissingLocalAssetFunction · 0.85
rewriteAssetPathsFunction · 0.85
rewriteCssAssetUrlsFunction · 0.85

Calls 2

needsRewriteFunction · 0.85
resolveFunction · 0.85

Tested by

no test coverage detected