decord/beta/source/modules/coded_links/findCodedLinkUrlsUsingRegex.tsx
github-actions 9b6fea255e chore: update source for beta 346.12
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-18 19:45:33 +00:00

29 lines
1,001 B
TypeScript

// Module ID: 13936
// Function ID: 13937
// Name: findCodedLinkUrlsUsingRegex
// Dependencies: [1366, 2]
// Exports: default
// Module 13936 (findCodedLinkUrlsUsingRegex)
import ip from "ip" /* 1366 */;
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 size = fn(2);
const result = size.fileFinishedImporting("modules/coded_links/findCodedLinkUrlsUsingRegex.tsx");
export default function findCodedLinkUrlsUsingRegex(str) {
const match = str.replaceAll(re1, " ").match(regExp);
let mapped;
if (match != null) {
mapped = match.map(trimTrailingPunctuation);
}
if (mapped == null) {
mapped = [];
}
return mapped;
};