From 13c1fa8e54b8a02854a0b15a19d54e0efa4968d6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 20 Aug 2024 11:19:42 +0200 Subject: Try verbatim search if FTS search syntax is invalid. --- server.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index 3ec7454..82adb93 100644 --- a/server.js +++ b/server.js @@ -1104,8 +1104,13 @@ app.post("/forum/reply/:thread_id", must_be_logged_in, function (req, res) { app.get("/forum/search", must_be_logged_in, function (req, res) { let search = req.query.q let results = [] - if (search) - results = FORUM_SEARCH.all(search) + if (search) { + try { + results = FORUM_SEARCH.all(search) + } catch (err) { + results = FORUM_SEARCH.all('"' + search.replaceAll('"', '""') + '"') + } + } res.render("forum_search.pug", { user: req.user, search, results }) }) -- cgit v1.2.3