Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: parse path without modifying query #2603

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions rasterio/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _ParsedPath(_Path):
@classmethod
def from_uri(cls, uri):
parts = urlparse(uri)
path = parts.path
path = pathlib.Path(parts.path).as_posix() if parts.path else parts.path
scheme = parts.scheme or None

if parts.query:
Expand All @@ -76,7 +76,7 @@ def from_uri(cls, uri):
parts = path.split('!')
path = parts.pop() if parts else None
archive = parts.pop() if parts else None
return _ParsedPath(pathlib.Path(path).as_posix(), archive, scheme)
return _ParsedPath(path, archive, scheme)

@property
def name(self):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def test_parse_gdal():
assert _parse_path('GDAL:filepath:varname').path == 'GDAL:filepath:varname'


def test_parse_http_password():
"""Make sure password unmodified GH2602"""
parsed = _parse_path('https://foo.tif?bar=a//b')
assert parsed.path == 'foo.tif?bar=a//b'
assert parsed.archive is None
assert parsed.scheme == 'https'


@pytest.mark.skipif(sys.platform == 'win32', reason="Checking behavior on posix, not win32")
def test_parse_windows_path(monkeypatch):
"""Return Windows paths unparsed"""
Expand Down