Skip to content

Commit

Permalink
Merge pull request zedeus#557 from jackyzy823/fix-bio-hashtag
Browse files Browse the repository at this point in the history
Fix bio hashtag
  • Loading branch information
zedeus authored Feb 20, 2022
2 parents 716e869 + c7a78a7 commit e789fdb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/experimental/parser/user.nim
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import std/[algorithm, unicode, re, strutils, strformat, options]
import std/[algorithm, unicode, re, strutils, strformat, options, nre]
import jsony
import utils, slices
import ../types/user as userType
from ../../types import User, Error

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>"

htRegex = re"(^|[^\w-_./?])([##$])([\w_]+)"
htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!</a>|">|#)"""
htReplace = "$1<a href=\"/search?q=%23$3\">$2$3</a>"

proc expandUserEntities(user: var User; raw: RawUser) =
Expand All @@ -29,7 +29,7 @@ proc expandUserEntities(user: var User; raw: RawUser) =

user.bio = orig.replacedWith(replacements, 0 .. orig.len)
.replacef(unRegex, unReplace)
.replacef(htRegex, htReplace)
.replace(htRegex, htReplace)

proc getBanner(user: RawUser): string =
if user.profileBannerUrl.len > 0:
Expand Down

0 comments on commit e789fdb

Please sign in to comment.