decord/source/__polyfill/01xxx/module_1370.js
github-actions e510164e6b chore: update source for alpha 346.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4759.js (118.4 MB)
2026-09-10 05:38:07 +00:00

113 lines
3 KiB
JavaScript

// Module ID: 1370
// Function ID: 1371
// Dependencies: []
// Exports: parse, serialize
// Module 1370
const re2 = /; */;
const re3 = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
export const parse = function parse(str, arg1) {
if (typeof str !== "string") {
const _TypeError = TypeError;
const typeError = new TypeError("argument str must be a string");
throw typeError;
} else {
let obj = arg1;
const obj2 = {};
if (!arg1) {
obj = {};
}
const parts = str.split(re2);
closure_1 = obj.decode || decodeURIComponent;
const item = parts.forEach((arr) => {
const index = arr.indexOf("=");
if (index >= 0) {
const trimmed = arr.substr(0, index).trim();
const str = arr.substr(0, index);
const trimmed1 = arr.substr(index + 1, arr.length).trim();
let substr = trimmed1;
if ("\"" == trimmed1[0]) {
substr = trimmed1.slice(1, -1);
}
if (null == obj2[trimmed]) {
tmp3[trimmed] = (function tryDecode(substr, fn) {
try {
return fn(substr);
} catch (err) {
return tmp;
}
})(substr, closure_1);
}
const str2 = arr.substr(index + 1, arr.length);
}
});
return obj2;
}
};
export const serialize = function serialize(arg0, arg1, arg2) {
let obj = arg2;
if (!arg2) {
obj = {};
}
if (re3.test(arg0)) {
const tmpResult = tmp(arg1);
if (tmpResult) {
if (!obj2.test(tmpResult)) {
const _TypeError2 = TypeError;
const typeError = new TypeError("argument val is invalid");
throw typeError;
}
}
const items = [`${arg0}=${tmp8}`];
if (null != obj.maxAge) {
const maxAge = obj.maxAge;
const _isNaN = isNaN;
if (isNaN(maxAge)) {
const _Error = Error;
const error = new Error("maxAge should be a Number");
throw error;
} else {
const _Math = Math;
items.push(`Max-Age=${Math.floor(maxAge)}`);
}
}
if (obj.domain) {
if (obj2.test(obj.domain)) {
items.push(`Domain=${obj.domain}`);
} else {
const _TypeError3 = TypeError;
const typeError1 = new TypeError("option domain is invalid");
throw typeError1;
}
}
if (obj.path) {
if (obj2.test(obj.path)) {
items.push(`Path=${obj.path}`);
} else {
const _TypeError4 = TypeError;
const typeError2 = new TypeError("option path is invalid");
throw typeError2;
}
}
if (obj.expires) {
const expires = obj.expires;
items.push(`Expires=${expires.toUTCString()}`);
}
if (obj.httpOnly) {
items.push("HttpOnly");
}
if (obj.secure) {
items.push("Secure");
}
if (obj.firstPartyOnly) {
items.push("First-Party-Only");
}
return items.join("; ");
} else {
const _TypeError = TypeError;
const typeError3 = new TypeError("argument name is invalid");
throw typeError3;
}
tmp = obj.encode || encodeURIComponent;
};