Strip trailing colons from link detection, add test (#1944)
This commit is contained in:
parent
842e183925
commit
60deea1762
5
.changeset/grumpy-vans-carry.md
Normal file
5
.changeset/grumpy-vans-carry.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'@atproto/api': patch
|
||||
---
|
||||
|
||||
Strip trailing colon from URLs in rich-text facet detection.
|
@ -47,7 +47,7 @@ export function detectFacets(text: UnicodeString): Facet[] | undefined {
|
||||
const start = text.utf16.indexOf(match[2], match.index)
|
||||
const index = { start, end: start + match[2].length }
|
||||
// strip ending puncuation
|
||||
if (/[.,;!?]$/.test(uri)) {
|
||||
if (/[.,;:!?]$/.test(uri)) {
|
||||
uri = uri.slice(0, -1)
|
||||
index.end--
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ describe('detectFacets', () => {
|
||||
'start middle end.com/foo/bar?baz=bux#hash',
|
||||
'newline1.com\nnewline2.com',
|
||||
'a example.com/index.php php link',
|
||||
'a trailing bsky.app: colon',
|
||||
|
||||
'not.. a..url ..here',
|
||||
'e.g.',
|
||||
@ -162,6 +163,7 @@ describe('detectFacets', () => {
|
||||
['example.com/index.php', 'https://example.com/index.php'],
|
||||
[' php link'],
|
||||
],
|
||||
[['a trailing '], ['bsky.app', 'https://bsky.app'], [': colon']],
|
||||
|
||||
[['not.. a..url ..here']],
|
||||
[['e.g.']],
|
||||
|
Loading…
x
Reference in New Issue
Block a user