Skip to content

Commit

Permalink
Fixes extra spaces after urls
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Feb 15, 2024
1 parent b2c7f15 commit ed7dcf9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class RichTextParser() {
parseHash(word, tags)
} else if (word.contains(".") && schemelessMatcher.find()) {
val url = schemelessMatcher.group(1) // url
val additionalChars = schemelessMatcher.group(4) // additional chars
val additionalChars = schemelessMatcher.group(4).ifEmpty { null } // additional chars
val pattern =
"""^([A-Za-z0-9-_]+(\.[A-Za-z0-9-_]+)+)(:[0-9]+)?(/[^?#]*)?(\?[^#]*)?(#.*)?"""
.toRegex(RegexOption.IGNORE_CASE)
Expand Down Expand Up @@ -307,7 +307,7 @@ class RichTextParser() {
if (hashtagMatcher.find()) {
val hashtag = hashtagMatcher.group(1)
if (hashtag != null) {
return HashTagSegment(word, hashtag, hashtagMatcher.group(2))
return HashTagSegment(word, hashtag, hashtagMatcher.group(2).ifEmpty { null })
}
}
} catch (e: Exception) {
Expand Down

0 comments on commit ed7dcf9

Please sign in to comment.