update parse

This commit is contained in:
Hailey
2024-06-18 10:13:08 -07:00
parent cafab82593
commit 44812299bb
2 changed files with 5 additions and 1 deletions
+2
View File
@@ -844,6 +844,7 @@ describe('parseStarterPackHttpUri', () => {
'https://bsky.app/start/testlover9000.com', 'https://bsky.app/start/testlover9000.com',
'https://bsky.app/start/testlover9000.com/rkey/other', 'https://bsky.app/start/testlover9000.com/rkey/other',
'https://bsky.app/start', 'https://bsky.app/start',
undefined,
] ]
const outputs = [ const outputs = [
{name: 'haileyok.com', rkey: 'rkey'}, {name: 'haileyok.com', rkey: 'rkey'},
@@ -852,6 +853,7 @@ describe('parseStarterPackHttpUri', () => {
null, null,
null, null,
null, null,
null,
] ]
it('returns the correct name and rkey when input is valid', () => { it('returns the correct name and rkey when input is valid', () => {
+3 -1
View File
@@ -24,10 +24,12 @@ export function createStarterPackLinkFromAndroidReferrer(
} }
} }
export function parseStarterPackHttpUri(uri: string): { export function parseStarterPackHttpUri(uri?: string): {
name?: string name?: string
rkey?: string rkey?: string
} | null { } | null {
if (!uri) return null
try { try {
const url = new URL(uri) const url = new URL(uri)
const parts = url.pathname.split('/') const parts = url.pathname.split('/')