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

96 lines
2.3 KiB
JavaScript

// Metro module 1521 (f1522).
let c1219_0, c1219_1, decode;
const decodeComponents = function decodeComponents(a0, a1) {
let r12;
try {
r12 = [decodeURIComponent(a0.join(""))];
} catch ($e) {
if (a0.length === 1) {
return a0;
}
const r4 = a1 ? a1 : 1;
const r18 = a0.slice(0, r4);
const r6 = a0.slice(r4);
return Array.prototype.concat.call([], decodeComponents(r18), decodeComponents(r6));
}
return r12;
};
decode = function decode(a0) {
let r12, length;
let r0 = a0;
try {
r12 = decodeURIComponent(a0);
} catch ($e) {
let r6 = a0.match(c1219_0) || [];
const r17 = 1 < r6.length;
let r18 = 1;
if (r17) {
do {
const r9 = decodeComponents(r6, r18).join("");
let r10 = r9.match(c1219_0);
const r23 = r18;
if (!r10) {
r10 = [];
}
r18 = r23 + 1;
length = r10.length;
r6 = r10;
r0 = r9;
} while (r18 < length);
}
return r0;
}
return r12;
};
c1219_0 = new RegExp("(%[a-f0-9]{2})|([^%]+?)", "gi");
c1219_1 = new RegExp("(%[a-f0-9]{2})+", "gi");
module.exports = function(a0) {
let r10, r14;
if (typeof a0 !== "string") {
throw new TypeError(`Expected \`encodedURI\` to be of type \`string\`, got \`${typeof a0}\``);
}
try {
const r9 = a0.replace(/\+/g, " ");
r10 = r9;
r14 = decodeURIComponent(r9);
} catch ($e) {
return (function customDecodeURIComponent(a0) {
let length;
const r8 = {
"%FE%FF": "��",
"%FF%FE": "��"
};
let r15 = c1219_1.exec(a0);
while (r15) {
const r5 = r15;
try {
r8[r5[0]] = decodeURIComponent(r5[0]);
} catch ($e) {
const r21 = decode(r5[0]);
if (r21 !== r5[0]) {
r8[r5[0]] = r21;
}
}
r15 = c1219_1.exec(a0);
}
r8["%C2"] = "�";
const r29 = Object.keys(r8);
const r31 = 0 < r29.length;
let r34 = 0;
let r35 = a0;
let r36 = a0;
if (r31) {
do {
const r37 = r29[r34];
r35 = r35.replace(new RegExp(r37, "g"), r8[r37]);
r34 = r34 + 1;
length = r29.length;
r36 = r35;
} while (r34 < length);
}
return r36;
})(r10);
}
return r14;
};