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

automod match_link fixes (#432)

* remove trailing dot from FQDN for TLD check

Signed-off-by: GitHub <noreply@github.com>

* yeet all trailing characters from TLDs

Signed-off-by: GitHub <noreply@github.com>

* oops

Signed-off-by: GitHub <noreply@github.com>

* move dumb loop to regex replace

Signed-off-by: GitHub <noreply@github.com>

---------

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
Tiago R 2023-12-29 11:43:36 +00:00 committed by GitHub
parent d09e0566b3
commit 7c946949d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -647,7 +647,13 @@ export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] {
return urls;
}
const hostnameParts = matchUrl.hostname.split(".");
let hostname = matchUrl.hostname.toLowerCase();
if (hostname.length > 3) {
hostname = hostname.replace(/[^a-z]+$/, "");
}
const hostnameParts = hostname.split(".");
const tld = hostnameParts[hostnameParts.length - 1];
if (tlds.includes(tld)) {
urls.push(matchUrl);