Files
console-dev/app/lib/auth-redirect.js
T
2026-11-06 00:04:38 +08:00

30 lines
592 B
JavaScript

function e(e) {
if (
typeof e != `string` ||
!e.startsWith(`/`) ||
e.startsWith(`//`) ||
/[\\\u0000-\u0020\u007f]/.test(e)
)
return `/`;
try {
let t = decodeURIComponent(e.split(/[?#]/, 1)[0] || ``);
if (t.startsWith(`//`) || /[\\\u0000-\u0020\u007f]/.test(t)) return `/`;
} catch {
return `/`;
}
return e;
}
function t(t) {
let n = e(t);
return n === `/`
? {}
: {
redirect: n,
};
}
function n(t, n) {
let r = e(n);
return r === `/` ? t : `${t}?redirect=${encodeURIComponent(r)}`;
}
export { t as n, e as r, n as t };