Skip to content

Commit

Permalink
Account for URI fragments in domains
Browse files Browse the repository at this point in the history
  • Loading branch information
TDKorn committed Dec 9, 2023
1 parent b62d6c9 commit 3fe486c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions magento/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def parse_domain(domain: str):
**Example**::
>>> parse_domain('https://www.mymagento.com/')
>>> parse_domain('https://www.mymagento.com#new-products')
'mymagento.com'
>>> parse_domain('https://www.my-magento.magento.com/')
'my-magento.magento.com'
>>> parse_domain('https://username:password@my-magento.mymagento.com:443/store')
'my-magento.mymagento.com'
"""
match = re.match(
pattern=r"^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)",
pattern=r"^(?:https?://)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?#]+)",
string=domain
)
if match:
Expand Down

0 comments on commit 3fe486c

Please sign in to comment.