header flattening

This commit is contained in:
velzie 2024-07-14 19:10:13 -04:00
parent a94cf9dd6a
commit d0df4a8357
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
2 changed files with 18 additions and 11 deletions

View file

@ -70,11 +70,16 @@ self.ScramjetServiceWorker = class ScramjetServiceWorker {
}
}
for (let header in responseHeaders) {
// flatten everything past here
if (responseHeaders[header] instanceof Array) responseHeaders[header] = responseHeaders[header][0];
}
if (response.body) {
switch (request.destination) {
case "iframe":
case "document":
if (responseHeaders["content-type"].toString().startsWith("text/html")) {
if (responseHeaders["content-type"]?.toString()?.startsWith("text/html")) {
responseBody = rewriteHtml(await response.text(), url);
} else {
responseBody = response.body;