···15151616 React.useEffect(() => {
1717 const handleIncomingURL = (url: string) => {
1818+ // We want to be able to support bluesky:// deeplinks. It's unnatural for someone to use a deeplink with three
1919+ // slashes, like bluesky:///intent/follow. However, supporting just two slashes causes us to have to take care
2020+ // of two cases when parsing the url. If we ensure there is a third slash, we can always ensure the first
2121+ // path parameter is in pathname rather than in hostname.
2222+ if (url.startsWith('bluesky://') && !url.startsWith('bluesky:///')) {
2323+ url = url.replace('bluesky://', 'bluesky:///')
2424+ }
2525+1826 const urlp = new URL(url)
1919- const [_, intentTypeNative, intentTypeWeb] = urlp.pathname.split('/')
2727+ const [_, intent, intentType] = urlp.pathname.split('/')
20282129 // On native, our links look like bluesky://intent/SomeIntent, so we have to check the hostname for the
2230 // intent check. On web, we have to check the first part of the path since we have an actual hostname
2323- const intentType = isNative ? intentTypeNative : intentTypeWeb
2424- const isIntent = isNative
2525- ? urlp.hostname === 'intent'
2626- : intentTypeNative === 'intent'
3131+ const isIntent = intent === 'intent'
2732 const params = urlp.searchParams
28332934 if (!isIntent) return
···6974 return false
7075 }
7176 // We also should just filter out cases that don't have all the info we need
7272- if (!VALID_IMAGE_REGEX.test(part)) {
7373- return false
7474- }
7575- return true
7777+ return VALID_IMAGE_REGEX.test(part)
7678 })
7779 .map(part => {
7880 const [uri, width, height] = part.split('|')