kopia lustrzana https://github.com/cloudflare/wildebeest
make enrichStatus accept mentioned with longer domain
rodzic
7a29d255ac
commit
561d5e03ca
|
@ -10,7 +10,7 @@ function tag(name: string, content: string, attrs: Record<string, string> = {}):
|
|||
}
|
||||
|
||||
const linkRegex = /(^|\s|\b)(https?:\/\/[-\w@:%._+~#=]{2,256}\.[a-z]{2,6}\b(?:[-\w@:%_+.~#?&/=]*))(\b|\s|$)/g
|
||||
const mentionedEmailRegex = /(^|\s|\b)@(\w+(?:[.-]?\w+)+@\w+(?:[.-]?\w+)+(?:\.\w{2,3})+)(\b|\s|$)/g
|
||||
const mentionedEmailRegex = /(^|\s|\b)@(\w+(?:[.-]?\w+)+@\w+(?:[.-]?\w+)+(?:\.\w{2,63})+)(\b|\s|$)/g
|
||||
|
||||
/// Transform a text status into a HTML status; enriching it with links / mentions.
|
||||
export function enrichStatus(status: string): string {
|
||||
|
|
|
@ -324,6 +324,16 @@ describe('Mastodon APIs', () => {
|
|||
enrichStatus('hi @test.a.b.c-d@example.eng.co.uk.....'),
|
||||
'<p>hi <span class="h-card"><a href="https://example.eng.co.uk/@test.a.b.c-d" class="u-url mention">@<span>test.a.b.c-d</span></a></span>.....</p>'
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
enrichStatus(`@testey@123456.abcdef, hi!`),
|
||||
'<p><span class="h-card"><a href="https://123456.abcdef/@testey" class="u-url mention">@<span>testey</span></a></span>, hi!</p>'
|
||||
)
|
||||
|
||||
assert.equal(
|
||||
enrichStatus(`@testey@123456.test.testey.abcdef`),
|
||||
'<p><span class="h-card"><a href="https://123456.test.testey.abcdef/@testey" class="u-url mention">@<span>testey</span></a></span></p>'
|
||||
)
|
||||
})
|
||||
|
||||
test('handle invalid mention', () => {
|
||||
|
|
Ładowanie…
Reference in New Issue