From 85815335601566c411cc1e223970b18e8233f8a1 Mon Sep 17 00:00:00 2001
From: Stephanie Freitag <stephanie.freitag@holi.team>
Date: Tue, 18 Feb 2025 15:35:20 +0100
Subject: [PATCH] NOISSUE: remove obsolete platform check in useLink

---
 core/navigation/hooks/__tests__/useLink.test.ts | 10 ++--------
 core/navigation/hooks/useLink.ts                | 13 +++++--------
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/core/navigation/hooks/__tests__/useLink.test.ts b/core/navigation/hooks/__tests__/useLink.test.ts
index 858a268050..c38c8e274e 100644
--- a/core/navigation/hooks/__tests__/useLink.test.ts
+++ b/core/navigation/hooks/__tests__/useLink.test.ts
@@ -1,7 +1,7 @@
 import useLink from '@holi/core/navigation/hooks/useLink'
 import useRouting from '@holi/core/navigation/hooks/useRouting'
 import { renderHook, waitFor } from '@testing-library/react-native'
-import { Linking, Platform } from 'react-native'
+import { Linking } from 'react-native'
 
 const mockUseRouting = jest.mocked(useRouting)
 jest.mock('@holi/core/navigation/hooks/useRouting', () => jest.fn())
@@ -79,17 +79,11 @@ describe('useLink', () => {
     expect(mockOpenURL).toHaveBeenCalledWith('/')
   })
 
-  it('should ignore domain and locale path param on mobile', () => {
-    const originalPlatform = Platform.OS
-    Platform.OS = 'android'
-
+  it('should ignore domain and locale path param', () => {
     const { result } = renderHook(() => useLink({ href: 'https://app.holi.social/en/spaces' }))
 
     result.current(testEvent)
 
     expect(mockNavigate).toHaveBeenCalledWith('/spaces')
-
-    // Clean up
-    Platform.OS = originalPlatform
   })
 })
diff --git a/core/navigation/hooks/useLink.ts b/core/navigation/hooks/useLink.ts
index 54cee39689..56305a762a 100644
--- a/core/navigation/hooks/useLink.ts
+++ b/core/navigation/hooks/useLink.ts
@@ -1,6 +1,6 @@
 import type React from 'react'
 import { useCallback } from 'react'
-import { type GestureResponderEvent, Linking, Platform } from 'react-native'
+import { type GestureResponderEvent, Linking } from 'react-native'
 
 import useRouting from '@holi/core/navigation/hooks/useRouting'
 
@@ -11,6 +11,7 @@ export interface UseLinkProps {
   external?: boolean
 }
 
+// This hook is for mobile only and is used inside HoliLink and HoliTextLink, which have alternative implementations for web.
 const useLink = ({ onPress, external, href }: UseLinkProps) => {
   const { navigate } = useRouting()
 
@@ -27,13 +28,9 @@ const useLink = ({ onPress, external, href }: UseLinkProps) => {
         return
       }
 
-      if (Platform.OS === 'ios' || Platform.OS === 'android') {
-        // If the platform is mobile and the link domain matches our app's domain, navigate to the route instead of opening the link
-        const route = '/' + href.replace(/https:\/\/(app\.holi\.social|staging\.dev\.holi\.social)(\/(en|de))?\/?/, '')
-        navigate(route)
-      } else {
-        navigate(href)
-      }
+      // If the platform is mobile and the link domain matches our app's domain, navigate to the route instead of opening the link
+      const route = '/' + href.replace(/https:\/\/(app\.holi\.social|staging\.dev\.holi\.social)(\/(en|de))?\/?/, '')
+      navigate(route)
     },
     [external, href, navigate, onPress]
   )
-- 
GitLab