Skip to content

Commit 3f0cc3e

Browse files
Copilotyarikoptic
andcommitted
Support all known instances in short URL format
Co-authored-by: yarikoptic <[email protected]>
1 parent c43062d commit 3f0cc3e

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

dandi/dandiarchive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,13 @@ class _dandi_url_parser:
589589
# for not only "dandiarchive.org" URLs
590590
(
591591
re.compile(
592-
rf"(?P<instance_name>DANDI):"
592+
rf"(?P<instance_name>[-\w._]+):"
593593
rf"{dandiset_id_grp}"
594594
rf"(/(?P<version>{VERSION_REGEX}))?",
595595
flags=re.I,
596596
),
597597
{},
598-
"DANDI:<dandiset id>[/<version>]",
598+
"<INSTANCE>:<dandiset id>[/<version>]",
599599
),
600600
(
601601
re.compile(r"https?://gui\.dandiarchive\.org/.*"),

dandi/tests/test_dandiarchive.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,55 @@
117117
version_id="0.210831.2033",
118118
),
119119
),
120+
# Test other instances with short format
121+
(
122+
"DANDI-SANDBOX:000029",
123+
DandisetURL(
124+
instance=known_instances["dandi-sandbox"],
125+
dandiset_id="000029",
126+
version_id=None,
127+
),
128+
),
129+
(
130+
"dandi-sandbox:000029/draft",
131+
DandisetURL(
132+
instance=known_instances["dandi-sandbox"],
133+
dandiset_id="000029",
134+
version_id="draft",
135+
),
136+
),
137+
(
138+
"LINC:000029",
139+
DandisetURL(
140+
instance=known_instances["linc"],
141+
dandiset_id="000029",
142+
version_id=None,
143+
),
144+
),
145+
(
146+
"linc:000029/0.210831.2033",
147+
DandisetURL(
148+
instance=known_instances["linc"],
149+
dandiset_id="000029",
150+
version_id="0.210831.2033",
151+
),
152+
),
153+
(
154+
"EMBER:000029",
155+
DandisetURL(
156+
instance=known_instances["ember"],
157+
dandiset_id="000029",
158+
version_id=None,
159+
),
160+
),
161+
(
162+
"ember-sandbox:000029/draft",
163+
DandisetURL(
164+
instance=known_instances["ember-sandbox"],
165+
dandiset_id="000029",
166+
version_id="draft",
167+
),
168+
),
120169
(
121170
"http://localhost:8000/api/dandisets/000002/",
122171
DandisetURL(

0 commit comments

Comments
 (0)