diff --git a/CHANGELOG.md b/CHANGELOG.md index 181c34020..870f93a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Fixed - Quickstart tutorial is now up-to-date with all package changes ([#674](https://github.com/stac-utils/pystac/pull/674)) +- Creating absolute URLs from absolute URLs ([#697](https://github.com/stac-utils/pystac/pull/697)]) ### Deprecated diff --git a/pystac/utils.py b/pystac/utils.py index 8232e7a0a..f79493db8 100644 --- a/pystac/utils.py +++ b/pystac/utils.py @@ -241,10 +241,13 @@ def make_absolute_href( parsed_start = safe_urlparse(start_href) parsed_source = safe_urlparse(source_href) - if JoinType.from_parsed_uri(parsed_start) == JoinType.PATH: - return _make_absolute_href_path(parsed_source, parsed_start, start_is_dir) - else: + if ( + JoinType.from_parsed_uri(parsed_source) == JoinType.URL + or JoinType.from_parsed_uri(parsed_start) == JoinType.URL + ): return _make_absolute_href_url(parsed_source, parsed_start, start_is_dir) + else: + return _make_absolute_href_path(parsed_source, parsed_start, start_is_dir) def is_absolute_href(href: str) -> bool: diff --git a/tests/test_utils.py b/tests/test_utils.py index 4f6e1d849..453dc6fcd 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -158,6 +158,7 @@ def test_make_absolute_href(self) -> None: "https://stacspec.org/a/b/c/catalog.json", "https://stacspec.org/a/b/item.json", ), + ("http://localhost:8000", None, "http://localhost:8000"), ] for source_href, start_href, expected in test_cases: