decord/source/modules/markup/MarkupAttachmentLinkRule.tsx

30 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 4848
// Function ID: 4849
2026-08-24 06:08:38 +00:00
// Name: regExp
2026-08-25 06:04:03 +00:00
// Dependencies: [4849, 4096, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 4848 (regExp)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
2026-08-25 06:04:03 +00:00
import tDefault from "t" /* 4096 */;
import set2 from "set" /* 4849 */;
2026-08-24 06:08:38 +00:00
const mapped = Array.from(set2.ATTACHMENT_PATH_PREFIXES).map((str) => str.replaceAll("/", ""));
const regExp = new RegExp("^https://(?:(?:media|images)\\.discordapp\\.net|(?:cdn\\.discordapp\\.com))/(?:" + mapped.join("|") + ")/\\d+/\\d+/([A-Za-z0-9._-]*[A-Za-z0-9_-])(?:[?][a-zA-Z0-9?&=_-]*)?");
2026-07-29 08:29:29 +00:00
let obj = { attachmentLink: null };
2026-07-20 16:05:17 +00:00
obj = {
2026-08-24 06:08:38 +00:00
order: tDefault.defaultRules.url.order - 0.5,
2026-07-23 10:11:24 +00:00
requiredFirstCharacters: ["h"],
2026-07-20 16:05:17 +00:00
match(arg0) {
2026-08-24 06:08:38 +00:00
return regExp.exec(arg0);
2026-07-20 16:05:17 +00:00
},
parse(attachmentUrl) {
const items = [{ type: "text", content: attachmentUrl[1] }];
return { type: "attachmentLink", content: items, attachmentUrl: attachmentUrl[0], attachmentName: attachmentUrl[1] };
}
};
2026-07-29 08:29:29 +00:00
obj[0] = obj;
2026-08-24 06:08:38 +00:00
const arr = Array.from(set2.ATTACHMENT_PATH_PREFIXES);
const result = set.fileFinishedImporting("modules/markup/MarkupAttachmentLinkRule.tsx");
2026-07-20 16:05:17 +00:00
export default obj;