@@ -51,16 +51,19 @@ def navigate_url(url):
51
51
asset_id ["version" ] = r ["most_recent_version" ]["version" ]
52
52
args = (asset_id ["dandiset_id" ], asset_id ["version" ])
53
53
kwargs ["include_metadata" ] = True
54
- if asset_id .get ("location" ):
54
+ if asset_id .get ("location" ) or asset_id . get ( "asset_id" ) :
55
55
with client .session ():
56
56
dandiset = client .get_dandiset (* args )
57
57
if asset_type == "folder" :
58
58
assets = client .get_dandiset_assets (
59
59
* args , path = asset_id ["location" ]
60
60
)
61
61
elif asset_type == "item" :
62
- asset = client .get_asset_bypath (* args , asset_id ["location" ])
63
- assets = [asset ] if asset is not None else []
62
+ if "location" in asset_id :
63
+ asset = client .get_asset_bypath (* args , asset_id ["location" ])
64
+ assets = [asset ] if asset is not None else []
65
+ else :
66
+ assets = [client .get_asset (* args , asset_id ["asset_id" ])]
64
67
else :
65
68
raise NotImplementedError (
66
69
f"Do not know how to handle asset type { asset_type } with location"
@@ -183,6 +186,16 @@ class _dandi_url_parser:
183
186
{"server_type" : "api" },
184
187
"https://<server>[/api]/dandisets/<dandiset id>[/versions[/<version>]]" ,
185
188
),
189
+ (
190
+ re .compile (
191
+ rf"{ server_grp } (?P<asset_type>dandiset)s/{ dandiset_id_grp } "
192
+ r"/versions/(?P<version>[.0-9]{5,}|draft)"
193
+ r"/assets/(?P<asset_id>[^/]+)(/(download/?)?)?"
194
+ ),
195
+ {"server_type" : "api" },
196
+ "https://<server>[/api]/dandisets/<dandiset id>/versions/<version>"
197
+ "/assets/<asset id>[/download]" ,
198
+ ),
186
199
# But for drafts files navigator it is a bit different beast and there
187
200
# could be no versions, only draft
188
201
# https://deploy-preview-341--gui-dandiarchive-org.netlify.app/#/dandiset/000027/draft/files?_id=5f176583f63d62e1dbd06943&_modelType=folder
@@ -353,6 +366,7 @@ def parse(cls, url, *, map_instance=True):
353
366
dandiset_id = groups .get ("dandiset_id" )
354
367
version = groups .get ("version" )
355
368
location = groups .get ("location" )
369
+ asset_key = groups .get ("asset_id" )
356
370
if location :
357
371
location = urlunquote (location )
358
372
# ATM carries leading '/' which IMHO is not needed/misguiding somewhat, so
@@ -371,6 +385,9 @@ def parse(cls, url, *, map_instance=True):
371
385
else :
372
386
asset_type = "item"
373
387
asset_ids ["location" ] = location
388
+ elif asset_key :
389
+ asset_type = "item"
390
+ asset_ids ["asset_id" ] = asset_key
374
391
# TODO: remove whenever API supports "draft" and this type of url
375
392
if groups .get ("id" ):
376
393
assert version == "draft"
0 commit comments