From 1af59ca8a7db308325f8964a131d544882cff6e8 Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Sat, 27 Apr 2024 05:25:28 +0100
Subject: 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>
---
 src/components/Link.tsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src/components/Link.tsx')

diff --git a/src/components/Link.tsx b/src/components/Link.tsx
index 65a015ba3..a2e952a6e 100644
--- a/src/components/Link.tsx
+++ b/src/components/Link.tsx
@@ -3,10 +3,12 @@ import {GestureResponderEvent} from 'react-native'
 import {sanitizeUrl} from '@braintree/sanitize-url'
 import {StackActions, useLinkProps} from '@react-navigation/native'
 
+import {BSKY_DOWNLOAD_URL} from '#/lib/constants'
 import {AllNavigatorParams} from '#/lib/routes/types'
 import {shareUrl} from '#/lib/sharing'
 import {
   convertBskyAppUrlIfNeeded,
+  isBskyDownloadUrl,
   isExternalUrl,
   linkRequiresWarning,
 } from '#/lib/strings/url-helpers'
@@ -125,7 +127,9 @@ export function useLink({
             (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
           const shouldOpenInNewTab = isMetaKey || isMiddleClick
 
-          if (
+          if (isBskyDownloadUrl(href)) {
+            shareUrl(BSKY_DOWNLOAD_URL)
+          } else if (
             shouldOpenInNewTab ||
             href.startsWith('http') ||
             href.startsWith('mailto')
-- 
cgit 1.4.1

