decord/source/modules/suspicious_downloads/SuspiciousDownloadUtils.tsx

101 lines
2.8 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 8380
// Function ID: 8381
2026-07-20 16:05:17 +00:00
// Name: set
2026-08-24 06:08:38 +00:00
// Dependencies: [8381, 1487, 2]
2026-07-20 16:05:17 +00:00
// Exports: isSuspiciousDownload
2026-08-24 06:08:38 +00:00
// Module 8380 (set)
import isDiscordProxiedAssetUrlDefault from "isDiscordProxiedAssetUrl" /* 1487 */;
import _modDef8381 from "module_8381" /* 8381 */;
import set from "set" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
let set = new Set(_modDef8381);
2026-07-29 08:29:29 +00:00
let obj = { "github.com": null, "bitbucket.org": null, "gitlab.com": null };
2026-07-20 16:05:17 +00:00
const regExp = new RegExp("/releases\\S*/download|archive/refs/\\S*|/i/raw/i/\\S*|/user-attachments\\S*");
2026-07-29 08:29:29 +00:00
obj[0] = regExp;
2026-07-20 16:05:17 +00:00
const regExp1 = new RegExp("/downloads\\S*/[^/]*");
2026-07-29 08:29:29 +00:00
obj[1] = regExp1;
2026-07-20 16:05:17 +00:00
const regExp2 = new RegExp("/downloads\\S*/[^/]*");
2026-07-29 08:29:29 +00:00
obj[2] = regExp2;
2026-07-23 10:11:24 +00:00
const result = set.fileFinishedImporting("modules/suspicious_downloads/SuspiciousDownloadUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const isSuspiciousDownload = function isSuspiciousDownload(localUri) {
2026-08-24 06:08:38 +00:00
obj = isDiscordProxiedAssetUrlDefault;
2026-07-29 08:29:29 +00:00
let toURLSafeResult = obj.toURLSafe(localUri);
if (toURLSafeResult == null) {
2026-07-20 16:05:17 +00:00
toURLSafeResult = {};
}
({ pathname, hostname } = toURLSafeResult);
if (null == hostname) {
return null;
} else {
if (null != obj[hostname]) {
if (null != pathname) {
if (!obj3.test(pathname)) {
return null;
}
}
}
if (null == pathname) {
return null;
} else {
2026-07-29 08:29:29 +00:00
try {
const _decodeURIComponent = decodeURIComponent;
const str = decodeURIComponent(pathname);
const parts = str.split("/");
2026-07-20 16:05:17 +00:00
let diff = parts.length - 1;
2026-07-29 08:29:29 +00:00
let tmp4 = null;
let num3 = 0;
if (0 <= diff) {
2026-07-20 16:05:17 +00:00
while (true) {
2026-07-29 08:29:29 +00:00
let tmp5 = parts[diff];
let tmp6 = diff;
let tmp7 = num3;
let sum = num3;
if ("" !== tmp5) {
sum = num3;
if ("." !== tmp5) {
if (".." !== tmp5) {
2026-07-20 16:05:17 +00:00
break;
} else {
2026-07-29 08:29:29 +00:00
sum = num3 + 1;
2026-07-20 16:05:17 +00:00
}
}
2026-07-23 10:11:24 +00:00
}
2026-07-29 08:29:29 +00:00
diff = diff - 1;
num3 = sum;
tmp4 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp4 = null;
if (diff >= num3) {
tmp4 = parts[diff - num3];
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (null == tmp4) {
2026-07-20 16:05:17 +00:00
return null;
} else {
2026-07-29 08:29:29 +00:00
const parts1 = tmp4.split(".");
2026-07-20 16:05:17 +00:00
if (parts1.length < 2) {
return null;
} else {
2026-07-29 08:29:29 +00:00
const str6 = parts1.pop();
2026-07-20 16:05:17 +00:00
let formatted;
2026-07-29 08:29:29 +00:00
if (str6 != null) {
formatted = str6.toLowerCase();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp10 = null;
2026-07-20 16:05:17 +00:00
if (null != formatted) {
2026-07-29 08:29:29 +00:00
tmp10 = null;
if (set.has(formatted)) {
tmp10 = formatted;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp10;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-07-20 16:05:17 +00:00
}
}
}
};