function sanitizeRedirectPath(rawRedirect, baseUrl, fallback) {
  if (!rawRedirect) return fallback;
  try {
    const base = new URL(baseUrl);
    const resolved = new URL(rawRedirect, baseUrl);
    if (resolved.origin !== base.origin) return fallback;
    if (!resolved.pathname.startsWith("/")) return fallback;
    if (resolved.pathname.includes("//")) return fallback;
    return resolved.pathname + resolved.search + resolved.hash;
  } catch {
    return fallback;
  }
}
export {
  sanitizeRedirectPath
};
//# sourceMappingURL=safeRedirect.js.map
