From f51cf18d8e5205b99d8be3d9c0b5e69f08741311 Mon Sep 17 00:00:00 2001 From: "kwrobel.eth" Date: Mon, 23 Sep 2024 17:23:43 +0200 Subject: [PATCH] Parse URL's hostname (#413) --- api/nameguard/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/nameguard/utils.py b/api/nameguard/utils.py index 91f82d045..2b13fab53 100644 --- a/api/nameguard/utils.py +++ b/api/nameguard/utils.py @@ -3,6 +3,7 @@ from ens.utils import Web3 from hexbytes import HexBytes from ens.constants import EMPTY_SHA3_BYTES +from urllib.parse import urlparse from nameguard.exceptions import InvalidNameHash, InvalidTokenID, InvalidEthereumAddress from nameguard.models import Rating, GenericCheckResult, Check @@ -223,13 +224,13 @@ def detect_grapheme_link_name(link: str) -> str: * https://unicode.link/inspect/utf8:{...} * http://📙.la/{...} """ - - if link.startswith('https://unicodeplus.com'): + host = urlparse(link).hostname + if host == 'unicodeplus.com': return 'UnicodePlus' - elif link.startswith('https://unicode.link'): + elif host == 'unicode.link': # title of th epage return 'Unicode Visualizer' - elif link.startswith('http://📙.la'): + elif host == '📙.la': return 'Emojipedia' else: return 'Unknown External Page'