mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-18 17:16:46 +03:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user