forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ trait StringHelper { self: NumberHelper => | |
// https://github.com/ornicar/lila/blob/master/modules/security/src/main/DataForm.scala#L34-L44 | ||
// Example: everyone says @ornicar is a pretty cool guy | ||
// False example: Write to [email protected], @1 | ||
private val atUsernameRegex = """\B@(?>[a-zA-Z_-][\w-]{1,19})(?U)(?![\w-])""".r | ||
private val atUsernameRegex = """\B@(?>([a-zA-Z_-][\w-]{1,19}))(?U)(?![\w-])""".r | ||
|
||
private val urlRegex = """(?i)\b((?:https?:https://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s<>]+|\(([^\s<>]+|(\([^\s<>]+\)))*\))+(?:\(([^\s<>]+|(\([^\s<>]+\)))*\)|[^\s`!\[\]{};:'".,<>?«»“”‘’]))""".r | ||
|
||
|
@@ -62,7 +62,7 @@ trait StringHelper { self: NumberHelper => | |
* @return The text as a HTML hyperlink | ||
*/ | ||
def addUserProfileLinks(text: String) = atUsernameRegex.replaceAllIn(text, m => { | ||
var user = m group 2 | ||
var user = m group 1 | ||
var url = s"$netDomain/@/$user" | ||
|
||
s"""<a href="${prependHttp(url)}">@$user</a>""" | ||
|