// Path: Loader/scripts/intent.js import { LOADER_DEFAULT_INTENT, LOADER_ROOT_PREFIX } from "./config.js"; export const getExplicitIntent = () => { const params = new URLSearchParams(window.location.search); const next = params.get("next"); if (typeof next === "string" && next.startsWith("/")) { return next; } return null; }; export const getCurrentPathIntent = () => { const current = `${window.location.pathname}${window.location.search}${window.location.hash}`; if (current === "/" || current === LOADER_ROOT_PREFIX || current === `${LOADER_ROOT_PREFIX}/` || current.startsWith(`${LOADER_ROOT_PREFIX}/`)) { return LOADER_DEFAULT_INTENT; } return current; }; export const resolveIntent = () => { return getExplicitIntent() ?? getCurrentPathIntent(); }; export const resolveHandoffTarget = (intent) => { return intent || LOADER_DEFAULT_INTENT; };