decord/beta/source/modules/markup/MarkupAttachmentLinkRule.tsx

41 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 16:32:48 +00:00
// Module ID: 5425
// Function ID: 5426
// Name: MarkupAttachmentLinkRule
2026-10-12 16:32:48 +00:00
// Dependencies: [5426, 1949, 2]
// Exports: matchAttachmentUrl
2026-10-12 16:32:48 +00:00
// Module 5425 (MarkupAttachmentLinkRule)
import _modDef1949 from "module_1949" /* 1949 */;
import AttachmentUrlConstants from "AttachmentUrlConstants" /* 5426 */;
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
function match(arg0) {
return regExp.exec(arg0);
}
function parse(attachmentUrl) {
let items;
const obj = { type: "attachmentLink", content: items, attachmentUrl: attachmentUrl[0], attachmentName: attachmentUrl[1] };
items = [{ type: "text", content: attachmentUrl[1] }];
return obj;
}
const arr = Array.from(AttachmentUrlConstants.ATTACHMENT_PATH_PREFIXES);
2026-10-01 14:13:23 +00:00
const mapped = arr.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?&=_-]*)?");
2026-10-12 16:32:48 +00:00
let obj = { attachmentLink: { order: _modDef1949.defaultRules.url.order - 0.5, requiredFirstCharacters: ["h"], match, parse } };
({ order: _modDef1949.defaultRules.url.order - 0.5, requiredFirstCharacters: ["h"], match, parse });
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) {
2026-10-01 14:13:23 +00:00
tmp2 = { name: match[1] };
const obj = { name: match[1] };
}
}
return tmp2;
};