Fix live script response encoding (#690)

Declare UTF-8 on the generated live and detector JavaScript responses and cover both endpoints with integration assertions.\n\nAI-assisted: prepared with Codex under @pbakaus direction.
This commit is contained in:
Paul Bakaus
2026-09-01 00:00:51 -04:00
committed by GitHub
parent 85d82c0afc
commit 632912b5ae
2 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -768,7 +768,7 @@ function createRequestHandler({ detectScript, liveScriptParts }) {
}),
});
res.writeHead(200, {
'Content-Type': 'application/javascript',
'Content-Type': 'application/javascript; charset=utf-8',
'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
'Pragma': 'no-cache',
});
@@ -777,7 +777,7 @@ function createRequestHandler({ detectScript, liveScriptParts }) {
}
if (p === '/detect.js' || p === '/') {
if (!detectScript) { res.writeHead(404); res.end('Not available'); return; }
res.writeHead(200, { 'Content-Type': 'application/javascript' });
res.writeHead(200, { 'Content-Type': 'application/javascript; charset=utf-8' });
res.end(detectScript);
return;
}
+4 -1
View File
@@ -350,7 +350,7 @@ describe('live-server integration', () => {
it('/live.js serves script with token injected', async () => {
const res = await fetch(`http://localhost:${server.port}/live.js?token=${server.token}`);
assert.equal(res.status, 200);
assert.equal(res.headers.get('content-type'), 'application/javascript');
assert.equal(res.headers.get('content-type'), 'application/javascript; charset=utf-8');
const text = await res.text();
assert.ok(text.includes('__IMPECCABLE_TOKEN__'));
assert.ok(text.includes(server.token));
@@ -545,6 +545,9 @@ colors: {}
const res = await fetch(`http://localhost:${server.port}/detect.js`);
// May 404 if detect-antipatterns-browser.js hasn't been built
assert.ok(res.status === 200 || res.status === 404);
if (res.status === 200) {
assert.equal(res.headers.get('content-type'), 'application/javascript; charset=utf-8');
}
});
it('/manual-edit-commit runs the batched AI apply path and clears successful entries', async () => {