summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-08-20 11:19:42 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-20 11:24:20 +0200
commit13c1fa8e54b8a02854a0b15a19d54e0efa4968d6 (patch)
tree7895d362fd8d57a006fddd2be2c14536e5a62c2c /server.js
parentc59ca4f0efe17213a6ba3a0f14cf3f525bf12ff6 (diff)
downloadserver-13c1fa8e54b8a02854a0b15a19d54e0efa4968d6.tar.gz
Try verbatim search if FTS search syntax is invalid.
Diffstat (limited to 'server.js')
-rw-r--r--server.js9
1 files changed, 7 insertions, 2 deletions
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 })
})