decord/alpha/source/modules/markup/MarkupAttachmentLinkRule.tsx
github-actions f95a0071ef chore: update source for alpha 349.1
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5021.js (118.4 MB)
2026-09-29 09:27:02 +00:00

43 lines
1.6 KiB
TypeScript

// Module ID: 5482
// Function ID: 5483
// Name: MarkupAttachmentLinkRule
// Dependencies: [5483, 1930, 2]
// Exports: matchAttachmentUrl
// Module 5482 (MarkupAttachmentLinkRule)
import _modDef1930 from "module_1930" /* 1930 */;
import AttachmentUrlConstants from "AttachmentUrlConstants" /* 5483 */;
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: _modDef1930.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;
export const matchAttachmentUrl = function matchAttachmentUrl(url) {
const match = regExp.exec(url);
let tmp2 = null;
if (null != match) {
tmp2 = null;
if (match[0] === url) {
const obj = { name: match[1] };
tmp2 = obj;
}
}
return tmp2;
};