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

Check if URL matches the API URL so we do not hardcode wrong "False" for is_api #1318

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ class ServerInfo(BaseModel):

def get_instance(dandi_instance_id: str | DandiInstance) -> DandiInstance:
dandi_id = None
is_api = True
redirector_url = None
if isinstance(dandi_instance_id, DandiInstance):
instance = dandi_instance_id
Expand All @@ -605,8 +606,10 @@ def get_instance(dandi_instance_id: str | DandiInstance) -> DandiInstance:
dandi_id = known_instances_rev.get(redirector_url.rstrip("/"))
if dandi_id is not None:
instance = known_instances[dandi_id]
is_api = instance.api.rstrip("/") == redirector_url.rstrip("/")
else:
instance = None
is_api = False
bits = urlparse(redirector_url)
redirector_url = urlunparse((bits[0], bits[1], "", "", "", ""))
else:
Expand All @@ -616,7 +619,7 @@ def get_instance(dandi_instance_id: str | DandiInstance) -> DandiInstance:
assert instance is not None
return _get_instance(instance.api.rstrip("/"), True, instance, dandi_id)
else:
return _get_instance(redirector_url.rstrip("/"), False, instance, dandi_id)
return _get_instance(redirector_url.rstrip("/"), is_api, instance, dandi_id)


@lru_cache
Expand Down