diff --git a/core/navigation/hooks/__tests__/useLink.test.ts b/core/navigation/hooks/__tests__/useLink.test.ts index 858a2680500cd79fdd9924987d29e14a2e0b11f1..c38c8e274e80854e5ed13752dd2092bb671099a9 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 54cee3968991b59f0564572ce98f670a0ada7d5f..56305a762a20e8169e2bd092b58c60fa522d7596 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] )