parent
31e4f08966
commit
4d73a3c2e3
|
@ -66,7 +66,7 @@ fun Spannable.highlightSpans(colour: Int, finders: List<PatternFinder> = default
|
||||||
|
|
||||||
for (finder in finders) {
|
for (finder in finders) {
|
||||||
// before running the regular expression, check if there is even a chance of it finding something
|
// before running the regular expression, check if there is even a chance of it finding something
|
||||||
if (this.contains(finder.searchString)) {
|
if (this.contains(finder.searchString, ignoreCase = true)) {
|
||||||
val matcher = finder.pattern.matcher(this)
|
val matcher = finder.pattern.matcher(this)
|
||||||
|
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
|
|
@ -115,6 +115,10 @@ class SpanUtilsTest(
|
||||||
arrayOf("😜https://connyduck.at", listOf(2 to 22)),
|
arrayOf("😜https://connyduck.at", listOf(2 to 22)),
|
||||||
arrayOf("😜#tag", listOf(2 to 6)),
|
arrayOf("😜#tag", listOf(2 to 6)),
|
||||||
arrayOf("😜@user@mastodon.example", listOf(2 to 24)),
|
arrayOf("😜@user@mastodon.example", listOf(2 to 24)),
|
||||||
|
// case should be ignored on protocols https://github.com/tuskyapp/Tusky/issues/4641
|
||||||
|
arrayOf("HTTPS://example.com", listOf(0 to 19)),
|
||||||
|
arrayOf("Http://example.com/test", listOf(0 to 23)),
|
||||||
|
arrayOf("test Https://example.com/test", listOf(5 to 29)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class StatusLengthTest(
|
||||||
arrayOf("🫣", 1),
|
arrayOf("🫣", 1),
|
||||||
// "@user@server" should be treated as "@user"
|
// "@user@server" should be treated as "@user"
|
||||||
arrayOf("123 @example@example.org", 12),
|
arrayOf("123 @example@example.org", 12),
|
||||||
// URLs under 23 chars are treated as 23 chars
|
// URLs are always treated as 23 even if they are shorter
|
||||||
arrayOf("123 http://example.org", 27),
|
arrayOf("123 http://example.org", 27),
|
||||||
// URLs over 23 chars are treated as 23 chars
|
// URLs over 23 chars are treated as 23 chars
|
||||||
arrayOf("123 http://urlthatislongerthan23characters.example.org", 27),
|
arrayOf("123 http://urlthatislongerthan23characters.example.org", 27),
|
||||||
|
@ -52,7 +52,11 @@ class StatusLengthTest(
|
||||||
// Long hashtags are *also* treated as is (not treated as 23, like URLs)
|
// Long hashtags are *also* treated as is (not treated as 23, like URLs)
|
||||||
arrayOf("123 #atagthatislongerthan23characters", 37),
|
arrayOf("123 #atagthatislongerthan23characters", 37),
|
||||||
// urls can have balanced parenthesis, otherwise they are ignored https://github.com/tuskyapp/Tusky/issues/4425
|
// urls can have balanced parenthesis, otherwise they are ignored https://github.com/tuskyapp/Tusky/issues/4425
|
||||||
arrayOf("(https://en.wikipedia.org/wiki/Beethoven_(horse))", 25)
|
arrayOf("(https://en.wikipedia.org/wiki/Beethoven_(horse))", 25),
|
||||||
|
// protocols can have any case https://github.com/tuskyapp/Tusky/issues/4641
|
||||||
|
arrayOf("Http://example.org", 23),
|
||||||
|
arrayOf("HTTPS://example.org", 23),
|
||||||
|
arrayOf("HTTPS://EXAMPLE.ORG", 23)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue