decord/beta/source/modules/coded_links/findCodedLinkUrlsUsingRegex.tsx

31 lines
1 KiB
TypeScript
Raw Normal View History

2026-10-07 22:43:51 +00:00
// Module ID: 13660
// Function ID: 13661
// Name: findCodedLinkUrlsUsingRegex
2026-10-07 22:43:51 +00:00
// Dependencies: [1372, 2]
// Exports: default
2026-10-07 22:43:51 +00:00
// Module 13660 (findCodedLinkUrlsUsingRegex)
import ip from "ip" /* 1372 */;
2026-10-01 14:13:23 +00:00
import size from "module_2" /* 2 */;
function trimTrailingPunctuation(str) {
return str.replace(re2, "");
}
const regExp = new RegExp("(?:(?:(?:https?:)?//)|www\\.)(?:[^\\s:@]+(?::[^\\s@]*)?@)?(?:localhost|" + ip.v4().source + "|(?:[a-z\\u00a1-\\uffff0-9-_]+\\.)+(?:(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#][^\\s\"()\\[\\]<>]*)?", "ig");
const re1 = /`{3,}[\s\S]*?(?:`{3,}|$)|(`{1,2})[^`]+\1(?!`)/g;
const re2 = /[.,;:?'*_~|]+$/;
const result = size.fileFinishedImporting("modules/coded_links/findCodedLinkUrlsUsingRegex.tsx");
export default function findCodedLinkUrlsUsingRegex(str) {
2026-10-01 14:13:23 +00:00
str = str.replaceAll(re1, " ");
const match = str.match(regExp);
let mapped;
if (match != null) {
mapped = match.map(trimTrailingPunctuation);
}
if (mapped == null) {
mapped = [];
}
return mapped;
};