Special-case searching for urls as these are not indexed in whole by postgres.

closes OLN-276
This commit is contained in:
Tom Moor
2024-04-21 11:51:52 -04:00
parent e2bc4c277b
commit 21537b069b
2 changed files with 37 additions and 14 deletions

View File

@@ -154,3 +154,13 @@ export function urlRegex(url: string | null | undefined): RegExp | undefined {
return new RegExp(escapeRegExp(`${urlObj.protocol}//${urlObj.host}`));
}
/**
* Extracts LIKELY urls from the given text, note this does not validate the urls.
*
* @param text The text to extract urls from.
* @returns An array of likely urls.
*/
export function getUrls(text: string) {
return Array.from(text.match(/(?:https?):\/\/[^\s]+/gi) || []);
}