From e671e502c32609d54bd31e70190550ef52092342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Fri, 20 Dec 2024 19:25:07 +0500 Subject: [PATCH] Enforce newlines at the end. --- index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 5e39164..7a7e90c 100644 --- a/index.ts +++ b/index.ts @@ -59,7 +59,11 @@ let srv = net.createServer(function(socket: net.Socket) { const store = db.prepare("INSERT INTO messages VALUES (?,?,?)"); let t = new Date; let a = addr; - let m = String(data.slice(1)).replace("/\n/g", "\\n").replace("/\x1b/g", "\\x1b"); + let s = data.slice(1); + if (s.slice(-1) != "\n") { + s += "\n"; + } + let m = String(s).replace("/\n/g", "\\n").replace("/\x1b/g", "\\x1b"); msize += textEncoder.encode(msgToString(t, a, m)).length store.run(Number(t),a,m); store.finalize();