mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
rewriters/html: only rewrite urls on real elements (needs to be merged with elements.ts later)
This commit is contained in:
parent
98f67d737c
commit
f4a4a0e7e4
1 changed files with 17 additions and 2 deletions
|
@ -38,7 +38,22 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
|
||||
/* url attributes */
|
||||
for (const urlAttr of ["src", "href", "action", "formaction"]) {
|
||||
if (hasAttrib(node, urlAttr) && !isScramjetFile(node.attribs[urlAttr])) {
|
||||
if (
|
||||
hasAttrib(node, urlAttr) &&
|
||||
!isScramjetFile(node.attribs[urlAttr]) &&
|
||||
[
|
||||
"iframe",
|
||||
"embed",
|
||||
"script",
|
||||
"a",
|
||||
"img",
|
||||
"link",
|
||||
"object",
|
||||
"form",
|
||||
"media",
|
||||
"source",
|
||||
].includes(node.name)
|
||||
) {
|
||||
const value = node.attribs[urlAttr];
|
||||
node.attribs[`data-${urlAttr}`] = value;
|
||||
node.attribs[urlAttr] = encodeUrl(value, origin);
|
||||
|
@ -76,7 +91,7 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
node.children[0].data = rewriteCss(node.children[0].data, origin);
|
||||
if (
|
||||
node.name === "script" &&
|
||||
/(application|text)\/javascript|importmap|undefined/.test(
|
||||
/(application|text)\/javascript|module|importmap|undefined/.test(
|
||||
node.attribs.type
|
||||
) &&
|
||||
node.children[0] !== undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue