Merge remote-tracking branch 'origin/main' into update-img-config
* origin/main: (31 commits) Add group chat join links to supported embed types (#10454) Disable overscroll on Android to fix settle discrepancy (#10717) Fix labeller highlight when selected on bottom bar (#10716) Use correct `Plural` macro in InviteLinkDialog (#10723) Fix invalid `zero` plural category and add plural formatting (#10722) Nightly source-language update `expo-image` tweaks (#10710) Make extra sure the drawer gesture doesn't accidentally trigger on Android (#10713) Fix image peek in carousels for quote posts (#10688) Compile i18n before running lint (#10711) [Android] Fix horizontal swipes being cancelled when leaving bounds (#10712) Enable ESLint errors and suppress existing violations (#10490) Hide accept button for locked chats (#10696) Mount message dialogs once at the list level (#10435) Fix alt text selection in lightbox on Android (and iOS) (#10698) Mention default `<Text>` style in CLAUDE.md (#10705) Use square icons for labellers in Automation Label preview card (#10701) [ALF] Set text to `leading_snug` by default (#10627) Nightly source-language update Transpile `@atproto/api` package for older browser support (#10700) ...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {describe, expect, it} from '@jest/globals'
|
||||
|
||||
import {
|
||||
getChatInviteCodeFromUrl,
|
||||
isPossiblyAUrl,
|
||||
isTrustedUrl,
|
||||
linkRequiresWarning,
|
||||
@@ -178,3 +179,47 @@ describe('isTrustedUrl', () => {
|
||||
expect(output).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getChatInviteCodeFromUrl', () => {
|
||||
type Case = [string, string | undefined]
|
||||
|
||||
const cases: Case[] = [
|
||||
['https://bsky.app/c/abcdefg', 'abcdefg'],
|
||||
['https://bsky.app/c/abcdefghij', 'abcdefghij'],
|
||||
// http is not recognized as a bsky.app url
|
||||
['http://bsky.app/c/abcdefg', undefined],
|
||||
['https://bsky.app/c/abcdefg?utm=foo', 'abcdefg'],
|
||||
['https://bsky.app/c/abcdefg#section', 'abcdefg'],
|
||||
['/c/abcdefg', 'abcdefg'],
|
||||
['/c/abcdefg?utm=foo', 'abcdefg'],
|
||||
['/c/abcdefg#section', 'abcdefg'],
|
||||
|
||||
// too short
|
||||
['https://bsky.app/c/abcdef', undefined],
|
||||
['/c/abcdef', undefined],
|
||||
// too long
|
||||
['https://bsky.app/c/abcdefghijk', undefined],
|
||||
['/c/abcdefghijk', undefined],
|
||||
// invalid characters
|
||||
['https://bsky.app/c/abc-def', undefined],
|
||||
['/c/abc def', undefined],
|
||||
// trailing path
|
||||
['https://bsky.app/c/abcdefg/extra', undefined],
|
||||
['/c/abcdefg/extra', undefined],
|
||||
// wrong path
|
||||
['https://bsky.app/profile/abcdefg', undefined],
|
||||
['https://bsky.app/c', undefined],
|
||||
// wrong host
|
||||
['https://example.com/c/abcdefg', undefined],
|
||||
// not a url, not a path
|
||||
['c/abcdefg', undefined],
|
||||
['abcdefg', undefined],
|
||||
['', undefined],
|
||||
// malformed url
|
||||
['https://[invalid/c/abcdefg', undefined],
|
||||
]
|
||||
|
||||
it.each(cases)('given input %p, returns %p', (input, expected) => {
|
||||
expect(getChatInviteCodeFromUrl(input)).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user