[object Object]

← back to New Import Viewer

fix: strip psql trailing newline from final field (stats newestCrawl + per-vendor crawled)

f6b1300179ee64d25c2a64bceb3ec5e7ab8dd00d · 2026-06-09 15:47:38 -0700 · SteveStudio2

Files touched

Diff

commit f6b1300179ee64d25c2a64bceb3ec5e7ab8dd00d
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Tue Jun 9 15:47:38 2026 -0700

    fix: strip psql trailing newline from final field (stats newestCrawl + per-vendor crawled)
---
 server.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/server.js b/server.js
index 1997a7f..7bdb7c8 100644
--- a/server.js
+++ b/server.js
@@ -23,8 +23,9 @@ function q(sql) {
   const r = spawnSync(PSQL, ['-U', PGUSER, '-d', PGDB, '-tA', '-F', US, '-R', RS, '-c', sql],
     { encoding: 'utf8', timeout: 30000, maxBuffer: 1 << 28 });
   if (r.status !== 0) throw new Error((r.stderr || 'psql failed').slice(0, 400));
-  // psql appends a trailing newline to the final record — strip per-row before split.
-  return (r.stdout || '').split(RS).map(l => l.replace(/\n+$/, '')).filter(l => l.length).map(l => l.split(US));
+  // psql appends a trailing newline to the whole output — strip it before splitting
+  // so the final field of the final row doesn't carry a stray \n.
+  return (r.stdout || '').replace(/\n+$/, '').split(RS).filter(l => l.length).map(l => l.split(US));
 }
 const esc = (s) => String(s == null ? '' : s).replace(/'/g, "''");
 const SORTS = {

← 1a10b71 new-import-viewer: agent + web viewer for products new-to-im  ·  back to New Import Viewer  ·  viewer: clean 'no image' placeholder on broken vendor image a368e81 →