From dcec1eb458886076f862622a5e841f82891df672 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 10 Feb 2026 22:53:54 +0100 Subject: [PATCH] Fix invalid search link formatting --- src/experimental/parser/slices.nim | 2 +- src/experimental/parser/user.nim | 2 +- src/formatters.nim | 2 +- src/parserutils.nim | 4 ++-- src/routes/search.nim | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/experimental/parser/slices.nim b/src/experimental/parser/slices.nim index 45e6e1d..db2c98d 100644 --- a/src/experimental/parser/slices.nim +++ b/src/experimental/parser/slices.nim @@ -54,7 +54,7 @@ proc replacedWith*(runes: seq[Rune]; repls: openArray[ReplaceSlice]; let name = $runes[rep.slice.a.succ .. rep.slice.b] symbol = $runes[rep.slice.a] - result.add a(symbol & name, href = "/search?q=%23" & name) + result.add a(symbol & name, href = "/search?f=tweets&q=%23" & name) of rkMention: result.add a($runes[rep.slice], href = rep.url, title = rep.display) of rkUrl: diff --git a/src/experimental/parser/user.nim b/src/experimental/parser/user.nim index 8517bdc..8b98e7f 100644 --- a/src/experimental/parser/user.nim +++ b/src/experimental/parser/user.nim @@ -9,7 +9,7 @@ let unReplace = "$1@$2" htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!|">|#)""" - htReplace = "$1$2$3" + htReplace = "$1$2$3" proc expandUserEntities(user: var User; raw: RawUser) = let diff --git a/src/formatters.nim b/src/formatters.nim index fc0e197..077c7c4 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -199,7 +199,7 @@ proc getTwitterLink*(path: string; params: Table[string, string]): string = proc getLocation*(u: User | Tweet): (string, string) = if "://" in u.location: return (u.location, "") let loc = u.location.split(":") - let url = if loc.len > 1: "/search?q=place:" & loc[1] else: "" + let url = if loc.len > 1: "/search?f=tweets&q=place:" & loc[1] else: "" (loc[0], url) proc getSuspended*(username: string): string = diff --git a/src/parserutils.nim b/src/parserutils.nim index b88c8d2..426d025 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -17,7 +17,7 @@ let unReplace = "$1@$2" htRegex = re"(^|[^\w-_./?])([#$]|#)([\w_]+)" - htReplace = "$1$2$3" + htReplace = "$1$2$3" type ReplaceSliceKind = enum @@ -207,7 +207,7 @@ proc replacedWith(runes: seq[Rune]; repls: openArray[ReplaceSlice]; let name = $runes[rep.slice.a.succ .. rep.slice.b] symbol = $runes[rep.slice.a] - result.add a(symbol & name, href = "/search?q=%23" & name) + result.add a(symbol & name, href = "/search?f=tweets&q=%23" & name) of rkMention: result.add a($runes[rep.slice], href = rep.url, title = rep.display) of rkUrl: diff --git a/src/routes/search.nim b/src/routes/search.nim index 4220427..86677c9 100644 --- a/src/routes/search.nim +++ b/src/routes/search.nim @@ -43,9 +43,9 @@ proc createSearchRouter*(cfg: Config) = resp Http404, showError("Invalid search", cfg) get "/hashtag/@hash": - redirect("/search?q=" & encodeUrl("#" & @"hash")) + redirect("/search?f=tweets&q=" & encodeUrl("#" & @"hash")) get "/opensearch": - let url = getUrlPrefix(cfg) & "/search?q=" + let url = getUrlPrefix(cfg) & "/search?f=tweets&q=" resp Http200, {"Content-Type": "application/opensearchdescription+xml"}, generateOpenSearchXML(cfg.title, cfg.hostname, url)