From 9dce492de402fe04a867668511181216710fcb27 Mon Sep 17 00:00:00 2001 From: Tiago R Date: Sun, 26 Nov 2023 12:04:39 +0000 Subject: [PATCH] remove trailing dot from FQDN for TLD check Signed-off-by: GitHub --- backend/src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 1bb4d6ce..da21ee46 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -647,7 +647,9 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] { return urls; } - const hostnameParts = matchUrl.hostname.split("."); + const hostname = matchUrl.hostname.endsWith(".") ? matchUrl.hostname.slice(0, -1) : matchUrl.hostname; + + const hostnameParts = hostname.split("."); const tld = hostnameParts[hostnameParts.length - 1]; if (tlds.includes(tld)) { urls.push(matchUrl);