diff --git a/protocol.py b/protocol.py index 39ee62e..ca4957e 100644 --- a/protocol.py +++ b/protocol.py @@ -4,7 +4,7 @@ from datetime import timedelta import logging import re from threading import Lock -from urllib.parse import urljoin +from urllib.parse import urljoin, urlparse from cachetools import cached, LRUCache from flask import g, request @@ -301,10 +301,11 @@ class Protocol: if not id: return None - # step 1: check for our per-protocol subdomains if util.is_web(id): + # step 1: check for our per-protocol subdomains + is_homepage = urlparse(id).path.strip('/') == '' by_subdomain = Protocol.for_bridgy_subdomain(id) - if by_subdomain: + if by_subdomain and not is_homepage: logger.info(f' {by_subdomain.LABEL} owns id {id}') return by_subdomain diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 23de109..50d3135 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -90,8 +90,13 @@ class ProtocolTest(TestCase): ('foo://bar', None), ('fake:foo', Fake), ('at://foo', ATProto), + # TODO: remove? should we require normalized ids? ('https://ap.brid.gy/foo/bar', ActivityPub), ('https://web.brid.gy/foo/bar', Web), + ('https://fed.brid.gy/', Web), + ('https://web.brid.gy/', Web), + ('https://bsky.brid.gy/', Web), + ('bsky.brid.gy', Web), ]: self.assertEqual(expected, Protocol.for_id(id, remote=False)) self.assertEqual(expected, Protocol.for_id(id, remote=True))