35 lines
877 B
TypeScript
35 lines
877 B
TypeScript
/**
|
|
* Share intent handler stub.
|
|
*
|
|
* When expo-share-intent is installed and the app is prebuilt,
|
|
* this module will receive URLs shared from other apps and route
|
|
* them to the intake confirmation screen.
|
|
*
|
|
* Currently a no-op stub — no native dependency required.
|
|
*/
|
|
|
|
import { router } from 'expo-router';
|
|
|
|
export type ShareIntentData = {
|
|
text?: string;
|
|
webUrl?: string;
|
|
type?: string;
|
|
};
|
|
|
|
/**
|
|
* Process a received share intent.
|
|
* Extracts the URL (if any) and navigates to the intake screen.
|
|
*/
|
|
export function handleShareIntent(data: ShareIntentData): void {
|
|
const url = data.webUrl ?? extractUrl(data.text);
|
|
if (!url) return;
|
|
|
|
router.push({ pathname: '/intake', params: { url } });
|
|
}
|
|
|
|
function extractUrl(text?: string): string | null {
|
|
if (!text) return null;
|
|
const match = text.match(/https?:\/\/[^\s]+/);
|
|
return match ? match[0] : null;
|
|
}
|