decord/stable/source/modules/markup/MarkupAttachmentLinkRule.tsx
github-actions e2bc0408ee chore: update source for stable 346.13
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-22 22:11:40 +00:00

30 lines
1.3 KiB
TypeScript

// Module ID: 5090
// Function ID: 5091
// Name: MarkupAttachmentLinkRule
// Dependencies: [5091, 4333, 2]
// Module 5090 (MarkupAttachmentLinkRule)
import _modDef4333 from "module_4333" /* 4333 */;
import AttachmentUrlConstants from "AttachmentUrlConstants" /* 5091 */;
import size from "module_2" /* 2 */;
const mapped = Array.from(AttachmentUrlConstants.ATTACHMENT_PATH_PREFIXES).map((item) => item.replaceAll("/", ""));
const regExp = new RegExp("^https://(?:[A-Za-z0-9-]+\\.)*(?:(?:media|images)" + "(?:-[A-Za-z0-9]+)?" + "\\.discordapp\\.net|(?:cdn" + "(?:-[A-Za-z0-9]+)?" + "\\.discordapp\\.com))/(?:" + mapped.join("|") + ")/\\d+/\\d+/([A-Za-z0-9._-]*[A-Za-z0-9_-])(?:[?][a-zA-Z0-9?&=_-]*)?");
let obj = { attachmentLink: null };
const arr = Array.from(AttachmentUrlConstants.ATTACHMENT_PATH_PREFIXES);
obj.attachmentLink = {
order: _modDef4333.defaultRules.url.order - 0.5,
requiredFirstCharacters: ["h"],
match(arg0) {
return regExp.exec(arg0);
},
parse(attachmentUrl) {
const obj = { type: "attachmentLink", content: null, attachmentUrl: attachmentUrl[0], attachmentName: attachmentUrl[1] };
const items = [{ type: "text", content: attachmentUrl[1] }];
obj.content = items;
return obj;
}
};
const result = size.fileFinishedImporting("modules/markup/MarkupAttachmentLinkRule.tsx");
export default obj;