Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify intent path logic, ensure all variations work for bluesky://, bluesky:///, and https://bsky.app/ (#3045)

* Simplify intent path logic, ensure all variations work

* use startsWith

authored by

Hailey and committed by
GitHub
8bf40b46 a7195ccb

+11 -9
+11 -9
src/lib/hooks/useIntentHandler.ts
··· 15 15 16 16 React.useEffect(() => { 17 17 const handleIncomingURL = (url: string) => { 18 + // We want to be able to support bluesky:// deeplinks. It's unnatural for someone to use a deeplink with three 19 + // slashes, like bluesky:///intent/follow. However, supporting just two slashes causes us to have to take care 20 + // of two cases when parsing the url. If we ensure there is a third slash, we can always ensure the first 21 + // path parameter is in pathname rather than in hostname. 22 + if (url.startsWith('bluesky://') && !url.startsWith('bluesky:///')) { 23 + url = url.replace('bluesky://', 'bluesky:///') 24 + } 25 + 18 26 const urlp = new URL(url) 19 - const [_, intentTypeNative, intentTypeWeb] = urlp.pathname.split('/') 27 + const [_, intent, intentType] = urlp.pathname.split('/') 20 28 21 29 // On native, our links look like bluesky://intent/SomeIntent, so we have to check the hostname for the 22 30 // intent check. On web, we have to check the first part of the path since we have an actual hostname 23 - const intentType = isNative ? intentTypeNative : intentTypeWeb 24 - const isIntent = isNative 25 - ? urlp.hostname === 'intent' 26 - : intentTypeNative === 'intent' 31 + const isIntent = intent === 'intent' 27 32 const params = urlp.searchParams 28 33 29 34 if (!isIntent) return ··· 69 74 return false 70 75 } 71 76 // We also should just filter out cases that don't have all the info we need 72 - if (!VALID_IMAGE_REGEX.test(part)) { 73 - return false 74 - } 75 - return true 77 + return VALID_IMAGE_REGEX.test(part) 76 78 }) 77 79 .map(part => { 78 80 const [uri, width, height] = part.split('|')