From 246093561b6c4fc5b50b5758ab964358e9218f9a Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Thu, 15 Jun 2023 10:00:02 -0400 Subject: [PATCH] Preserve URL parse parameters when recursing --- dandi/dandiarchive.py | 6 +++--- dandi/tests/test_dandiarchive.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dandi/dandiarchive.py b/dandi/dandiarchive.py index 1a78f5f0e..be32d0bcb 100644 --- a/dandi/dandiarchive.py +++ b/dandi/dandiarchive.py @@ -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) 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 @@ -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) if settings["map_instance"] not in known_instances: raise ValueError( "Unknown instance {}. Known are: {}".format( diff --git a/dandi/tests/test_dandiarchive.py b/dandi/tests/test_dandiarchive.py index fbe7d9e5b..690fda63f 100644 --- a/dandi/tests/test_dandiarchive.py +++ b/dandi/tests/test_dandiarchive.py @@ -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",