Skip to content

Commit

Permalink
Preserve URL parse parameters when recursing
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Jun 15, 2023
1 parent 9007788 commit 2460935
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dandi/dandiarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@ def parse(
assert not handle_redirect
assert not settings.get("map_instance")
new_url = rewrite(url)
return cls.parse(new_url)
return cls.parse(new_url, map_instance=map_instance, glob=glob)

Check warning on line 697 in dandi/dandiarchive.py

View check run for this annotation

Codecov / codecov/patch

dandi/dandiarchive.py#L697

Added line #L697 was not covered by tests
elif handle_redirect:
assert handle_redirect in ("pass", "only")
new_url = cls.follow_redirect(url)
if new_url != url:
return cls.parse(new_url)
return cls.parse(new_url, map_instance=map_instance, glob=glob)
if handle_redirect == "pass":
# We used to issue warning in such cases, but may be it got implemented
# now via reverse proxy and we had added a new regex? let's just
Expand All @@ -712,7 +712,7 @@ def parse(
)
elif settings.get("map_instance"):
if map_instance:
parsed_url = cls.parse(url, map_instance=False)
parsed_url = cls.parse(url, map_instance=False, glob=glob)

Check warning on line 715 in dandi/dandiarchive.py

View check run for this annotation

Codecov / codecov/patch

dandi/dandiarchive.py#L715

Added line #L715 was not covered by tests
if settings["map_instance"] not in known_instances:
raise ValueError(
"Unknown instance {}. Known are: {}".format(
Expand Down
10 changes: 10 additions & 0 deletions dandi/tests/test_dandiarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@ def test_parse_api_url(url: str, parsed_url: ParsedDandiURL) -> None:
@pytest.mark.parametrize(
"url,parsed_url",
[
(
"https://dandiarchive.org/dandiset/001001/draft/files"
"?location=sub-RAT123/*.nwb",
AssetGlobURL(
instance=known_instances["dandi"],
dandiset_id="001001",
version_id="draft",
path="sub-RAT123/*.nwb",
),
),
pytest.param(
"https://gui.dandiarchive.org/#/dandiset/001001/draft/files"
"?location=sub-RAT123/*.nwb",
Expand Down

0 comments on commit 2460935

Please sign in to comment.