3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix error when getUrlsInString doesn't match any URLs

This commit is contained in:
Dragory 2019-09-29 15:57:08 +03:00
parent a905e82492
commit 490dc587a2

View file

@ -185,7 +185,7 @@ const urlRegex = /(\S+\.\S+)/g;
const protocolRegex = /^[a-z]+:\/\//;
export function getUrlsInString(str: string, unique = false): url.URL[] {
let matches = str.match(urlRegex).map(m => m[0]) || [];
let matches = (str.match(urlRegex) || []).map(m => m[0]);
if (unique) matches = Array.from(new Set(matches));
return matches.reduce((urls, match) => {