mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 11:06:30 +00:00
Merge pull request #557 from jackyzy823/fix-bio-hashtag
Fix bio hashtag
This commit is contained in:
commit
e789fdbe5a
1 changed files with 4 additions and 4 deletions
|
@ -1,14 +1,14 @@
|
||||||
import std/[algorithm, unicode, re, strutils, strformat, options]
|
import std/[algorithm, unicode, re, strutils, strformat, options, nre]
|
||||||
import jsony
|
import jsony
|
||||||
import utils, slices
|
import utils, slices
|
||||||
import ../types/user as userType
|
import ../types/user as userType
|
||||||
from ../../types import User, Error
|
from ../../types import User, Error
|
||||||
|
|
||||||
let
|
let
|
||||||
unRegex = re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
unRegex = re.re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
||||||
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
||||||
|
|
||||||
htRegex = re"(^|[^\w-_./?])([##$])([\w_]+)"
|
htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!</a>|">|#)"""
|
||||||
htReplace = "$1<a href=\"/search?q=%23$3\">$2$3</a>"
|
htReplace = "$1<a href=\"/search?q=%23$3\">$2$3</a>"
|
||||||
|
|
||||||
proc expandUserEntities(user: var User; raw: RawUser) =
|
proc expandUserEntities(user: var User; raw: RawUser) =
|
||||||
|
@ -29,7 +29,7 @@ proc expandUserEntities(user: var User; raw: RawUser) =
|
||||||
|
|
||||||
user.bio = orig.replacedWith(replacements, 0 .. orig.len)
|
user.bio = orig.replacedWith(replacements, 0 .. orig.len)
|
||||||
.replacef(unRegex, unReplace)
|
.replacef(unRegex, unReplace)
|
||||||
.replacef(htRegex, htReplace)
|
.replace(htRegex, htReplace)
|
||||||
|
|
||||||
proc getBanner(user: RawUser): string =
|
proc getBanner(user: RawUser): string =
|
||||||
if user.profileBannerUrl.len > 0:
|
if user.profileBannerUrl.len > 0:
|
||||||
|
|
Loading…
Reference in a new issue