diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-19 19:51:35 +0000 |
---|---|---|
committer | Samuel Newman <mozzius@protonmail.com> | 2024-03-19 19:51:35 +0000 |
commit | 4794ab6b9a39d06bb0d1b7c64a315e4ac5e3336a (patch) | |
tree | 743b94dff5a4a3b4b2304c53b984b8a3dc67aaa2 /__tests__/lib | |
parent | a1c4f19731878f7026d398d28e475bbeb7de824a (diff) | |
parent | 5621c8042510c86f6c4fa63b5c5ce9fc02b0bf8e (diff) | |
download | voidsky-4794ab6b9a39d06bb0d1b7c64a315e4ac5e3336a.tar.zst |
Merge remote-tracking branch 'origin/main' into samuel/alf-login
Diffstat (limited to '__tests__/lib')
-rw-r--r-- | __tests__/lib/strings/url-helpers.test.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/__tests__/lib/strings/url-helpers.test.ts b/__tests__/lib/strings/url-helpers.test.ts index 6ac31aeb6..fb4b8f755 100644 --- a/__tests__/lib/strings/url-helpers.test.ts +++ b/__tests__/lib/strings/url-helpers.test.ts @@ -4,6 +4,7 @@ import { linkRequiresWarning, isPossiblyAUrl, splitApexDomain, + isTrustedUrl, } from '../../../src/lib/strings/url-helpers' describe('linkRequiresWarning', () => { @@ -74,6 +75,10 @@ describe('linkRequiresWarning', () => { // bad uri inputs, default to true ['', '', true], ['example.com', 'example.com', true], + ['/profile', 'Username', false], + ['#', 'Show More', false], + ['https://docs.bsky.app', 'https://docs.bsky.app', false], + ['https://bsky.app/compose/intent?text=test', 'Compose a post', false], ] it.each(cases)( @@ -139,3 +144,36 @@ describe('splitApexDomain', () => { }, ) }) + +describe('isTrustedUrl', () => { + const cases = [ + ['#', true], + ['#profile', true], + ['/', true], + ['/profile', true], + ['/profile/', true], + ['/profile/bob.test', true], + ['https://bsky.app', true], + ['https://bsky.app/', true], + ['https://bsky.app/profile/bob.test', true], + ['https://www.bsky.app', true], + ['https://www.bsky.app/', true], + ['https://docs.bsky.app', true], + ['https://bsky.social', true], + ['https://bsky.social/blog', true], + ['https://blueskyweb.xyz', true], + ['https://blueskyweb.zendesk.com', true], + ['http://bsky.app', true], + ['http://bsky.social', true], + ['http://blueskyweb.xyz', true], + ['http://blueskyweb.zendesk.com', true], + ['https://google.com', false], + ['https://docs.google.com', false], + ['https://google.com/#', false], + ] + + it.each(cases)('given input uri %p, returns %p', (str, expected) => { + const output = isTrustedUrl(str) + expect(output).toEqual(expected) + }) +}) |