Fix the tag span generation for tags with nonascii characters (#2700)
* Update mention and tag regexes from mastodon * Normalize nonascii tag names the same way that mastodon does
This commit is contained in:
parent
687cffd540
commit
5d09a67b52
5 changed files with 44 additions and 3 deletions
|
@ -38,6 +38,7 @@ class SpanUtilsTest {
|
|||
return listOf(
|
||||
"@mention",
|
||||
"#tag",
|
||||
"#tåg",
|
||||
"https://thr.ee/meh?foo=bar&wat=@at#hmm",
|
||||
"http://thr.ee/meh?foo=bar&wat=@at#hmm"
|
||||
)
|
||||
|
|
|
@ -86,6 +86,17 @@ class LinkHelperTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenCheckingTags_tagNameIsNormalized() {
|
||||
val mutator = "aeiou".toList().zip("åÉîøÜ".toList()).toMap()
|
||||
for (tag in tags) {
|
||||
val mutatedTagName = String(tag.name.map { mutator[it] ?: it }.toCharArray())
|
||||
val tagName = getTagName("#$mutatedTagName", tags)
|
||||
Assert.assertNotNull(tagName)
|
||||
Assert.assertNotNull(tags.firstOrNull { it.name == tagName })
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hashedUrlSpans_withNoMatchingTag_areNotModified() {
|
||||
for (tag in tags) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue