Skip to content

Commit

Permalink
Merge pull request #375 from kikkomep/fix-next-route-fetch
Browse files Browse the repository at this point in the history
fix next route fetch
  • Loading branch information
kikkomep authored Jan 16, 2024
2 parents 481e1c4 + f34229e commit 91d6fb1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lifemonitor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ def pop(cls, default=None, skipValidation=False):
# if the route is not defined as param, try to get it from the registry
if route is None:
registry = cls._get_route_registry()
logger.debug("Route registry: %r", registry)
try:
route = registry.pop()
logger.debug("Route registry changed: %r", registry)
Expand All @@ -1080,8 +1081,12 @@ def pop(cls, default=None, skipValidation=False):
cls._save_route_registry(registry)
if skipValidation:
return route or default
# if the route is not defined, set the default route as next route
if not route:
route = default
# validate the actual route
try:
logger.debug("Validating route: %r", route)
cls.validate_next_route_url(route)
except ValidationError as e:
logger.error(e)
Expand All @@ -1108,11 +1113,13 @@ def validate_next_route_url(cls, url: str) -> bool:
# check whether the URL is valid
url_domain = None
try:
logger.debug("Validating URL: %r", url)
url_domain = get_netloc(url)
except Exception as e:
if logger.isEnabledFor(logging.DEBUG):
logger.exception(e)
# check whether a url domain has been extracted
logger.debug("URL domain: %r", url_domain)
if url_domain is None:
raise ValidationError("Invalid URL: unable to detect domain")
# check if the URL domain matches the main domain of the back-end app
Expand Down

0 comments on commit 91d6fb1

Please sign in to comment.