37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
export type StartupDeepLinkIntent =
|
|
| "felicaHistory"
|
|
| "trainInfo"
|
|
| "operation"
|
|
| "settings"
|
|
| "topMenu"
|
|
| "positions";
|
|
|
|
const STARTUP_DEEP_LINK_PATTERNS: ReadonlyArray<{
|
|
intent: StartupDeepLinkIntent;
|
|
patterns: readonly string[];
|
|
}> = [
|
|
{
|
|
intent: "felicaHistory",
|
|
patterns: ["felicahistorypage", "open/felica"],
|
|
},
|
|
{ intent: "trainInfo", patterns: ["open/traininfo"] },
|
|
{ intent: "operation", patterns: ["open/operation"] },
|
|
{ intent: "settings", patterns: ["open/settings"] },
|
|
{ intent: "topMenu", patterns: ["open/topmenu"] },
|
|
{ intent: "positions", patterns: ["positions/apps"] },
|
|
];
|
|
|
|
/** Parse a supported app URL without touching navigation or timers. */
|
|
export const parseStartupDeepLinkIntent = (
|
|
url: string | null | undefined,
|
|
): StartupDeepLinkIntent | null => {
|
|
const normalized = (url ?? "").trim().toLowerCase();
|
|
if (!normalized) return null;
|
|
|
|
return (
|
|
STARTUP_DEEP_LINK_PATTERNS.find(({ patterns }) =>
|
|
patterns.some((pattern) => normalized.includes(pattern)),
|
|
)?.intent ?? null
|
|
);
|
|
};
|