decord/source/__polyfill/13xxx/module_13010.js
github-actions da5b5e5efe chore: update source for alpha 346.6
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-12 13:45:10 +00:00

48 lines
1.3 KiB
JavaScript

// Module ID: 13010
// Function ID: 13011
// Dependencies: []
// Exports: parseCookie
// Module 13010
export const parseCookie = function parseCookie(arr) {
const obj = {};
let num = 0;
if (0 < arr.length) {
let index = arr.indexOf("=", num);
while (-1 !== index) {
let length = arr.indexOf(";", num);
if (-1 === length) {
length = arr.length;
} else if (length < index) {
let sum = arr.lastIndexOf(";", index - 1) + 1;
num = sum;
if (sum >= arr.length) {
break;
}
}
let str = arr.slice(num, index);
let trimmed = str.trim();
if (undefined === obj[trimmed]) {
let str2 = arr.slice(index + 1, length);
let trimmed1 = str2.trim();
index = trimmed1;
if (34 === trimmed1.charCodeAt(0)) {
index = trimmed1.slice(1, -1);
}
try {
let decodeURIComponentResult = index;
if (-1 !== index.indexOf("%")) {
let _decodeURIComponent = decodeURIComponent;
decodeURIComponentResult = decodeURIComponent(index);
}
obj[trimmed] = decodeURIComponentResult;
} catch (err) {
obj[trimmed] = index;
}
}
let sum1 = length + 1;
}
}
return obj;
};