FIX: Correctly rewrite script/link tags in the proxy (#25204)

Regressed in fe10a3feab

Fixes /theme-qunit
This commit is contained in:
Jarek Radosz 2024-01-10 14:49:33 +01:00 committed by GitHub
parent 7a8cbf8422
commit bcb31f79ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,10 +44,28 @@ function updateScriptReferences({
}
}
const newElements = chunks.map(
(chunk) =>
`<script ${attribute}="${baseURL}${chunk}" data-ember-cli-rewritten="true"></script>`
);
const newElements = chunks.map((chunk) => {
let newElement = `<${element.tagName}`;
for (const [attr, value] of element.attributes) {
if (attr === attribute) {
newElement += ` ${attribute}="${baseURL}${chunk}"`;
} else if (value === "") {
newElement += ` ${attr}`;
} else {
newElement += ` ${attr}="${value}"`;
}
}
newElement += ` data-ember-cli-rewritten="true"`;
newElement += `>`;
if (element.tagName === "script") {
newElement += `</script>`;
}
return newElement;
});
if (
entrypointName === "discourse" &&