fix: improve permalink handling somewhat

This commit is contained in:
Daniel Roe 2022-12-01 22:59:08 +00:00
parent 131d1af827
commit 6dfc94e2a5
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
3 changed files with 31 additions and 2 deletions

23
tests/permalinks.test.ts Normal file
View file

@ -0,0 +1,23 @@
import { describe, expect, it } from 'vitest'
import { HANDLED_MASTO_URLS } from '../constants'
const validPermalinks = [
'https://m1as-social34.to.social/@elk',
'https://m1as-social34.to.social/@elk22/123',
'https://m1as-social34.to.social/@elk22/objects/123',
'mas.to/@elk',
]
const invalidPermalinks = [
'https://mas.to',
'https://mas.to/elk/123',
]
describe('permalinks', () => {
it.each(validPermalinks)('should recognise %s', (url) => {
expect(HANDLED_MASTO_URLS.test(url)).toBe(true)
})
it.each(invalidPermalinks)('should not recognise %s', (url) => {
expect(HANDLED_MASTO_URLS.test(url)).toBe(false)
})
})