From bcb31f79cea5e90ccee01c9b93142116963441f8 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 10 Jan 2024 14:49:33 +0100 Subject: [PATCH] FIX: Correctly rewrite script/link tags in the proxy (#25204) Regressed in fe10a3feab0f8dbf0476812c0987ad198f0b14cf Fixes /theme-qunit --- .../javascripts/bootstrap-json/index.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/bootstrap-json/index.js b/app/assets/javascripts/bootstrap-json/index.js index 6936c330383..f4aee92f832 100644 --- a/app/assets/javascripts/bootstrap-json/index.js +++ b/app/assets/javascripts/bootstrap-json/index.js @@ -44,10 +44,28 @@ function updateScriptReferences({ } } - const newElements = chunks.map( - (chunk) => - `` - ); + 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 += ``; + } + + return newElement; + }); if ( entrypointName === "discourse" &&