Bluesky app fork with some witchin' additions 💫

Special-case bsky.app/download to open share sheet or copy to clipboard (#3710)

* special-case bsky.app/download to share

* Address feedback

* Improve detection

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by samuel.fm

Dan Abramov and committed by
GitHub
1af59ca8 b10c96f2

+24 -10
+4 -3
__tests__/lib/strings/url-helpers.test.ts
··· 1 - import {it, describe, expect} from '@jest/globals' 1 + import {describe, expect, it} from '@jest/globals' 2 2 3 3 import { 4 - linkRequiresWarning, 5 4 isPossiblyAUrl, 5 + isTrustedUrl, 6 + linkRequiresWarning, 6 7 splitApexDomain, 7 - isTrustedUrl, 8 8 } from '../../../src/lib/strings/url-helpers' 9 9 10 10 describe('linkRequiresWarning', () => { ··· 170 170 ['https://google.com', false], 171 171 ['https://docs.google.com', false], 172 172 ['https://google.com/#', false], 173 + ['https://blueskywebxzendesk.com', false], 173 174 ] 174 175 175 176 it.each(cases)('given input uri %p, returns %p', (str, expected) => {
+5 -1
src/components/Link.tsx
··· 3 3 import {sanitizeUrl} from '@braintree/sanitize-url' 4 4 import {StackActions, useLinkProps} from '@react-navigation/native' 5 5 6 + import {BSKY_DOWNLOAD_URL} from '#/lib/constants' 6 7 import {AllNavigatorParams} from '#/lib/routes/types' 7 8 import {shareUrl} from '#/lib/sharing' 8 9 import { 9 10 convertBskyAppUrlIfNeeded, 11 + isBskyDownloadUrl, 10 12 isExternalUrl, 11 13 linkRequiresWarning, 12 14 } from '#/lib/strings/url-helpers' ··· 125 127 (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) 126 128 const shouldOpenInNewTab = isMetaKey || isMiddleClick 127 129 128 - if ( 130 + if (isBskyDownloadUrl(href)) { 131 + shareUrl(BSKY_DOWNLOAD_URL) 132 + } else if ( 129 133 shouldOpenInNewTab || 130 134 href.startsWith('http') || 131 135 href.startsWith('mailto')
+1
src/lib/constants.ts
··· 10 10 export const HELP_DESK_URL = `https://blueskyweb.zendesk.com/hc/${HELP_DESK_LANG}` 11 11 export const EMBED_SERVICE = 'https://embed.bsky.app' 12 12 export const EMBED_SCRIPT = `${EMBED_SERVICE}/static/embed.js` 13 + export const BSKY_DOWNLOAD_URL = 'https://bsky.app/download' 13 14 14 15 const BASE_FEEDBACK_FORM_URL = `${HELP_DESK_URL}/requests/new` 15 16 export function FEEDBACK_FORM_URL({
+14 -6
src/lib/strings/url-helpers.ts
··· 1 1 import {AtUri} from '@atproto/api' 2 - import {BSKY_SERVICE} from 'lib/constants' 2 + import psl from 'psl' 3 3 import TLDs from 'tlds' 4 - import psl from 'psl' 4 + 5 + import {BSKY_SERVICE} from 'lib/constants' 5 6 6 7 export const BSKY_APP_HOST = 'https://bsky.app' 7 8 const BSKY_TRUSTED_HOSTS = [ 8 - 'bsky.app', 9 - 'bsky.social', 10 - 'blueskyweb.xyz', 11 - 'blueskyweb.zendesk.com', 9 + 'bsky\\.app', 10 + 'bsky\\.social', 11 + 'blueskyweb\\.xyz', 12 + 'blueskyweb\\.zendesk\\.com', 12 13 ...(__DEV__ ? ['localhost:19006', 'localhost:8100'] : []), 13 14 ] 14 15 ··· 143 144 } 144 145 } 145 146 return false 147 + } 148 + 149 + export function isBskyDownloadUrl(url: string): boolean { 150 + if (isExternalUrl(url)) { 151 + return false 152 + } 153 + return url === '/download' || url.startsWith('/download?') 146 154 } 147 155 148 156 export function convertBskyAppUrlIfNeeded(url: string): string {