2026-10-10 08:08:14 +00:00
|
|
|
// Module ID: 5425
|
|
|
|
|
// Function ID: 5426
|
2026-09-10 05:38:07 +00:00
|
|
|
// Name: MarkupAttachmentLinkRule
|
2026-10-10 08:08:14 +00:00
|
|
|
// Dependencies: [5426, 1949, 2]
|
2026-09-24 10:59:02 +00:00
|
|
|
// Exports: matchAttachmentUrl
|
2026-07-20 16:05:17 +00:00
|
|
|
|
2026-10-10 08:08:14 +00:00
|
|
|
// Module 5425 (MarkupAttachmentLinkRule)
|
2026-10-09 10:00:15 +00:00
|
|
|
import _modDef1949 from "module_1949" /* 1949 */;
|
2026-10-10 08:08:14 +00:00
|
|
|
import AttachmentUrlConstants from "AttachmentUrlConstants" /* 5426 */;
|
2026-09-10 05:38:07 +00:00
|
|
|
import size from "module_2" /* 2 */;
|
2026-08-24 06:08:38 +00:00
|
|
|
|
2026-10-03 08:58:59 +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;
|
|
|
|
|
}
|
2026-09-10 05:38:07 +00:00
|
|
|
const arr = Array.from(AttachmentUrlConstants.ATTACHMENT_PATH_PREFIXES);
|
2026-10-03 08:58:59 +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-09 10:00:15 +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 });
|
2026-09-10 05:38:07 +00:00
|
|
|
const result = size.fileFinishedImporting("modules/markup/MarkupAttachmentLinkRule.tsx");
|
2026-07-20 16:05:17 +00:00
|
|
|
|
|
|
|
|
export default obj;
|
2026-09-24 10:59:02 +00:00
|
|
|
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-03 08:58:59 +00:00
|
|
|
tmp2 = { name: match[1] };
|
2026-09-24 10:59:02 +00:00
|
|
|
const obj = { name: match[1] };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp2;
|
|
|
|
|
};
|