Skip to content

Commit 6ad8c3e

Browse files
committed
update relative link logic in Link
1 parent 4e46270 commit 6ad8c3e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pystac/link.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ def get_href(self):
8282
else:
8383
href = self.target
8484

85-
if href and self.owner is not None:
86-
rel_links = HIERARCHICAL_LINKS + pystac.STAC_EXTENSIONS.get_extended_object_links(self.owner)
85+
if href and is_absolute_href(href) and self.owner and self.owner.get_root():
86+
root = self.owner.get_root()
87+
rel_links = HIERARCHICAL_LINKS + \
88+
pystac.STAC_EXTENSIONS.get_extended_object_links(self.owner)
8789
# if a hierarchical link with an owner and root, and relative catalog
88-
if self.rel in rel_links:
89-
root = self.owner.get_root()
90-
if root is not None and root.catalog_type in ['RELATIVE_PUBLISHED', 'SELF_CONTAINED']:
91-
if href and is_absolute_href(href):
92-
href = make_relative_href(href, self.owner.get_self_href())
90+
if root.is_relative() and self.rel in rel_links:
91+
href = make_relative_href(href, self.owner.get_self_href())
9392

9493
return href
9594

0 commit comments

Comments
 (0)