Make live update badge injection robust
This commit is contained in:
parent
c3f32acdd8
commit
51435b9307
@ -3,8 +3,7 @@ import http from 'node:http';
|
||||
const originalEnd = http.ServerResponse.prototype.end;
|
||||
|
||||
http.ServerResponse.prototype.end = function (chunk, encoding, callback) {
|
||||
const type = String(this.getHeader('content-type') || '');
|
||||
if (typeof chunk === 'string' && type.startsWith('text/html') && chunk.includes('</body>')) {
|
||||
if (typeof chunk === 'string' && chunk.includes('</body>')) {
|
||||
const badge = '<div style="position:fixed;right:16px;bottom:16px;background:#1f6feb;color:#fff;padding:8px 12px;border-radius:999px;font:600 12px system-ui;box-shadow:0 8px 24px #0006">v2 · live update</div>';
|
||||
chunk = chunk.replace('</body>', `${badge}</body>`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user