mirror of
https://github.com/zedeus/nitter.git
synced 2026-03-05 13:30:19 -05:00
Fix invalid search link formatting
This commit is contained in:
@@ -54,7 +54,7 @@ proc replacedWith*(runes: seq[Rune]; repls: openArray[ReplaceSlice];
|
|||||||
let
|
let
|
||||||
name = $runes[rep.slice.a.succ .. rep.slice.b]
|
name = $runes[rep.slice.a.succ .. rep.slice.b]
|
||||||
symbol = $runes[rep.slice.a]
|
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:
|
of rkMention:
|
||||||
result.add a($runes[rep.slice], href = rep.url, title = rep.display)
|
result.add a($runes[rep.slice], href = rep.url, title = rep.display)
|
||||||
of rkUrl:
|
of rkUrl:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ let
|
|||||||
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
||||||
|
|
||||||
htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!</a>|">|#)"""
|
htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!</a>|">|#)"""
|
||||||
htReplace = "$1<a href=\"/search?q=%23$3\">$2$3</a>"
|
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
||||||
|
|
||||||
proc expandUserEntities(user: var User; raw: RawUser) =
|
proc expandUserEntities(user: var User; raw: RawUser) =
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ proc getTwitterLink*(path: string; params: Table[string, string]): string =
|
|||||||
proc getLocation*(u: User | Tweet): (string, string) =
|
proc getLocation*(u: User | Tweet): (string, string) =
|
||||||
if "://" in u.location: return (u.location, "")
|
if "://" in u.location: return (u.location, "")
|
||||||
let loc = u.location.split(":")
|
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)
|
(loc[0], url)
|
||||||
|
|
||||||
proc getSuspended*(username: string): string =
|
proc getSuspended*(username: string): string =
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ let
|
|||||||
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
||||||
|
|
||||||
htRegex = re"(^|[^\w-_./?])([#$]|#)([\w_]+)"
|
htRegex = re"(^|[^\w-_./?])([#$]|#)([\w_]+)"
|
||||||
htReplace = "$1<a href=\"/search?q=%23$3\">$2$3</a>"
|
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
||||||
|
|
||||||
type
|
type
|
||||||
ReplaceSliceKind = enum
|
ReplaceSliceKind = enum
|
||||||
@@ -207,7 +207,7 @@ proc replacedWith(runes: seq[Rune]; repls: openArray[ReplaceSlice];
|
|||||||
let
|
let
|
||||||
name = $runes[rep.slice.a.succ .. rep.slice.b]
|
name = $runes[rep.slice.a.succ .. rep.slice.b]
|
||||||
symbol = $runes[rep.slice.a]
|
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:
|
of rkMention:
|
||||||
result.add a($runes[rep.slice], href = rep.url, title = rep.display)
|
result.add a($runes[rep.slice], href = rep.url, title = rep.display)
|
||||||
of rkUrl:
|
of rkUrl:
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ proc createSearchRouter*(cfg: Config) =
|
|||||||
resp Http404, showError("Invalid search", cfg)
|
resp Http404, showError("Invalid search", cfg)
|
||||||
|
|
||||||
get "/hashtag/@hash":
|
get "/hashtag/@hash":
|
||||||
redirect("/search?q=" & encodeUrl("#" & @"hash"))
|
redirect("/search?f=tweets&q=" & encodeUrl("#" & @"hash"))
|
||||||
|
|
||||||
get "/opensearch":
|
get "/opensearch":
|
||||||
let url = getUrlPrefix(cfg) & "/search?q="
|
let url = getUrlPrefix(cfg) & "/search?f=tweets&q="
|
||||||
resp Http200, {"Content-Type": "application/opensearchdescription+xml"},
|
resp Http200, {"Content-Type": "application/opensearchdescription+xml"},
|
||||||
generateOpenSearchXML(cfg.title, cfg.hostname, url)
|
generateOpenSearchXML(cfg.title, cfg.hostname, url)
|
||||||
|
|||||||
Reference in New Issue
Block a user