Files
discord-decomp/modules/suspicious_downloads/SuspiciousDownloadUtils.tsx
T
2026-11-01 12:12:55 +02:00

68 lines
1.6 KiB
TypeScript

// Metro module 7906 (f7907).
import Module7907 from "../../_bundle/Module7907";
import URLUtils from "../../utils/URLUtils";
let c4998_2 = new Set(Module7907);
let c4998_3 = {
"github.com": new RegExp("/releases\\S*/download|archive/refs/\\S*|/i/raw/i/\\S*|/user-attachments\\S*"),
"bitbucket.org": new RegExp("/downloads\\S*/[^/]*"),
"gitlab.com": new RegExp("/downloads\\S*/[^/]*")
};
export function isSuspiciousDownload(a0) {
let r29;
let r19 = URLUtils.toURLSafe(a0);
if (r19 == null) {
r19 = {};
}
const { pathname, hostname } = r19;
if (hostname == null) {
return null;
}
const r23 = c4998_3[hostname];
if (r23 != null && pathname != null && !r23.test(pathname)) {
return null;
}
if (pathname == null) {
return null;
}
try {
r29 = decodeURIComponent(pathname);
} catch ($e) {}
const r34 = r29.split("/");
let r12 = r34.length - 1;
let r37 = null;
let r8 = 0;
while (0 <= r12) {
const r14 = r34[r12];
const r7 = r12;
const r38 = r8;
let r15 = r38;
if (r14 !== "") {
r15 = r38;
if (r14 !== ".") {
if (r14 !== "..") {
r37 = null;
if (r7 < r38) {
break;
}
r37 = r34[r7 - r38];
break;
}
r15 = r38 + 1;
}
}
r12 = r7 - 1;
r8 = r15;
r37 = null;
}
if (r37 == null) {
return null;
}
const r41 = r37.split(".");
if (r41.length < 2) {
return null;
}
const r45 = r41.pop();
const r47 = r45 == null ? void 0 : r45.toLowerCase();
return r47 != null ? c4998_2.has(r47) ? r47 : null : null;
}