Files
discord-decomp/_bundle/Module4107.js
T
2026-11-01 12:12:55 +02:00

84 lines
2.2 KiB
JavaScript

// Metro module 4107 (f4108).
let decodeURIComponent2, encodeURIComponent2, c2365_2, c2365_3;
export function parse(a0, a1) {
if (typeof a0 !== "string") {
throw new TypeError("argument str must be a string");
}
let r2 = a1;
const r0 = {};
let c13856_0 = r0;
if (!a1) {
r2 = {};
}
const r9 = a0.split(c2365_2);
const decodeURIComponent3 = r2.decode || decodeURIComponent2;
r9.forEach(function(item) {
const r8 = item.indexOf("=");
if (!(r8 < 0)) {
const r11 = item.substr(0, r8).trim();
const r16 = item.substr(r8 + 1, item.length).trim();
const r19 = r16[0] == "\"" ? r16.slice(1, -1) : r16;
if (c13856_0[r11] == null) {
c13856_0[r11] = (function tryDecode(a0, a1) {
let r3;
try {
r3 = a1(a0);
} catch ($e) {
return a0;
}
return r3;
})(r19, decodeURIComponent3);
}
}
});
return r0;
}
export function serialize(a0, a1, a2) {
const r4 = a2 ? a2 : {};
const r5 = r4.encode || encodeURIComponent2;
if (c2365_3.test(a0)) {
const r18 = r5(a1);
if (r18 && !c2365_3.test(r18)) {
throw new TypeError("argument val is invalid");
}
const r31 = [a0 + "=" + r18];
if (r4.maxAge != null) {
const r34 = r4.maxAge - 0;
if (isNaN(r34)) {
throw new Error("maxAge should be a Number");
}
r31.push("Max-Age=" + Math.floor(r34));
}
if (r4.domain) {
if (!c2365_3.test(r4.domain)) {
throw new TypeError("option domain is invalid");
}
r31.push("Domain=" + r4.domain);
}
if (r4.path) {
if (!c2365_3.test(r4.path)) {
throw new TypeError("option path is invalid");
}
r31.push("Path=" + r4.path);
}
if (r4.expires) {
r31.push("Expires=" + r4.expires.toUTCString());
}
if (r4.httpOnly) {
r31.push("HttpOnly");
}
if (r4.secure) {
r31.push("Secure");
}
if (r4.firstPartyOnly) {
r31.push("First-Party-Only");
}
return r31.join("; ");
}
throw new TypeError("argument name is invalid");
}
decodeURIComponent2 = decodeURIComponent;
encodeURIComponent2 = encodeURIComponent;
c2365_2 = /; */;
c2365_3 = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;