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

30 lines
1,001 B
TypeScript
Raw Normal View History

// Module ID: 13375
// Function ID: 13376
// Name: findCodedLinkUrlsUsingRegex
// Dependencies: [1367, 2]
2026-08-25 06:04:03 +00:00
// Exports: default
// Module 13375 (findCodedLinkUrlsUsingRegex)
import ip from "ip" /* 1367 */;
2026-08-25 06:04:03 +00:00
function trimTrailingPunctuation(str) {
return str.replace(re2, "");
2026-08-25 06:04:03 +00:00
}
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");
2026-08-25 06:04:03 +00:00
const re1 = /`{3,}[\s\S]*?(?:`{3,}|$)|(`{1,2})[^`]+\1(?!`)/g;
const re2 = /[.,;:?'*_~|]+$/;
const size = fn(2);
const result = size.fileFinishedImporting("modules/coded_links/findCodedLinkUrlsUsingRegex.tsx");
2026-08-25 06:04:03 +00:00
export default function findCodedLinkUrlsUsingRegex(str) {
const match = str.replaceAll(re1, " ").match(regExp);
2026-08-25 06:04:03 +00:00
let mapped;
if (match != null) {
mapped = match.map(trimTrailingPunctuation);
}
if (mapped == null) {
mapped = [];
}
return mapped;
};