Files
console-dev/app/lib/order-image-continuation.js
T
2026-11-06 00:04:38 +08:00

43 lines
1022 B
JavaScript

var e = Symbol(`order-login-continuation`);
function t(e) {
if (typeof e != `number` && typeof e != `string`) return;
let t = Number(e);
if (!(
!Number.isSafeInteger(t) ||
t <= 0 ||
(typeof e == `string` && String(t) !== e)
))
return t;
}
function n(e) {
let t = decodeURIComponent(e);
return (
t.startsWith(`/`) &&
!t.startsWith(`//`) &&
!/[\\\u0000-\u0020\u007f]/.test(t)
);
}
function r(e, r) {
try {
if (
typeof e != `string` ||
/[\\\u0000-\u0020\u007f]/.test(e) ||
!n(e.split(/[?#]/, 1)[0] || ``)
)
return `/products`;
let i = new URL(e, `https://console.invalid`);
if (i.origin !== `https://console.invalid` || !n(i.pathname))
return `/products`;
let a = t(r);
return (
a === void 0
? i.searchParams.delete(`order_image`)
: i.searchParams.set(`order_image`, String(a)),
`${i.pathname}${i.search}${i.hash}`
);
} catch {
return `/products`;
}
}
export { r as n, t as r, e as t };