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

Function rewriteHtmlAttributes

packages/cli/src/utils/publishProject.ts:246–264  ·  view source on GitHub ↗
(
  ctx: ExternalAssetContext,
  document: Document,
  referrerAbsDir: string,
  entryPath: string,
)

Source from the content-addressed store, hash-verified

244}
245
246function rewriteHtmlAttributes(
247 ctx: ExternalAssetContext,
248 document: Document,
249 referrerAbsDir: string,
250 entryPath: string,
251): boolean {
252 let modified = false;
253 for (const el of document.querySelectorAll("[src], [href]")) {
254 for (const attr of ["src", "href"]) {
255 const val = (el.getAttribute(attr) || "").trim();
256 if (!val) continue;
257 const archivePath = tryResolveExternal(ctx, val, referrerAbsDir);
258 if (!archivePath) continue;
259 el.setAttribute(attr, posix.relative(posix.dirname(entryPath), archivePath));
260 modified = true;
261 }
262 }
263 return modified;
264}
265
266function rewriteStyleBlocks(
267 ctx: ExternalAssetContext,

Callers 1

localizeHtmlEntryFunction · 0.85

Calls 3

tryResolveExternalFunction · 0.85
getAttributeMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected