Skip to content

Commit

Permalink
Parse URL's hostname (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
djstrong authored Sep 23, 2024
1 parent ee0590d commit f51cf18
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/nameguard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'

0 comments on commit f51cf18

Please sign in to comment.