import { Platform } from 'react-native'; import { getSchemeUri } from '../../native-modules'; export function useInitialRouteName(prefix: string) { const initialScheme = getInitialScheme(); const pathname = initialScheme?.slice(prefix.length).split('?')[0]; const shouldUseIndex = initialScheme == null || pathname?.length === 0; return shouldUseIndex ? '/' : pathname; } function getInitialScheme() { const scheme = getSchemeUri(); /** * Android 에서 끝에 `/` 가 있는 경우 제거합니다. */ if (Platform.OS === 'android') { return scheme?.replaceAll(/\/+$/g, ''); } return scheme; }