( ctx: ExternalAssetContext, document: Document, referrerAbsDir: string, entryPath: string, )
| 244 | } |
| 245 | |
| 246 | function 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 | |
| 266 | function rewriteStyleBlocks( |
| 267 | ctx: ExternalAssetContext, |
no test coverage detected