From 16e28d02c672bdeb8066077c05b61089b3374b84 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Thu, 30 Nov 2023 11:25:01 +0100 Subject: [PATCH] Fix getting the instance domain name This used to return 3000 when running locally on localhost:3000 --- toot/auth.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/toot/auth.py b/toot/auth.py index 0311013..b9a0597 100644 --- a/toot/auth.py +++ b/toot/auth.py @@ -50,16 +50,11 @@ def get_instance_domain(base_url): # Pleroma and its forks return an actual URI here, rather than a # domain name like Mastodon. This is contrary to the spec.¯ # in that case, parse out the domain and return it. + uri = instance["uri"] + if uri.startswith("http"): + return urlparse(uri).netloc - parsed_uri = urlparse(instance["uri"]) - - if parsed_uri.netloc: - # Pleroma, Akkoma, GotoSocial, etc. - return parsed_uri.netloc - else: - # Others including Mastodon servers - return parsed_uri.path - + return uri # NB: when updating to v2 instance endpoint, this field has been renamed to `domain`