Skip to content

Commit b99032d

Browse files
committed
fix: require scheme and netloc for stac io urls
This fixes local path detection in windoze.
1 parent 1a4f535 commit b99032d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pystac_client/stac_api_io.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def read_text(self, source: pystac.link.HREF, *args: Any, **kwargs: Any) -> str:
100100
)
101101
else: # str or something that can be str'ed
102102
href = str(source)
103-
if bool(urlparse(href).scheme):
103+
if _is_url(href):
104104
return self.request(href, *args, **kwargs)
105105
else:
106106
with open(href) as f:
@@ -156,7 +156,7 @@ def request(
156156
raise APIError(str(err))
157157

158158
def write_text_to_href(self, href: str, *args: Any, **kwargs: Any) -> None:
159-
if bool(urlparse(href).scheme):
159+
if _is_url(href):
160160
raise APIError("Transactions not supported")
161161
else:
162162
return super().write_text_to_href(href, *args, **kwargs)
@@ -288,3 +288,8 @@ def conforms_to(self, conformance_class: ConformanceClasses) -> bool:
288288
def set_conformance(self, conformance: Optional[List[str]]) -> None:
289289
"""Sets (or clears) the conformance classes for this StacIO."""
290290
self._conformance = conformance
291+
292+
293+
def _is_url(href: str) -> bool:
294+
url = urlparse(href)
295+
return bool(url.scheme) and bool(url.netloc)

0 commit comments

Comments
 (0)