Skip to content

Commit

Permalink
check scheme and netloc for completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariana Barzinpour committed May 15, 2024
1 parent 3275dd0 commit fd5c098
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/dc_tools/odc/apps/dc_tools/_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@ def _get_relative_path(asset_href, self_link):
if self_link is None:
return asset_href

self_path = urlparse(self_link).path
href_path = urlparse(asset_href).path
self_parsed = urlparse(self_link)
href_parsed = urlparse(asset_href)

# keep as an absolute link if scheme or netloc differ
if self_parsed.scheme != href_parsed.scheme:
return asset_href
if self_parsed.netloc != href_parsed.netloc:
return asset_href

self_path = self_parsed.path
href_path = href_parsed.path

try:
return str(Path(href_path).relative_to(Path(self_path).parent))
Expand Down

0 comments on commit fd5c098

Please sign in to comment.