diff --git a/federation/tests/utils/test_diaspora.py b/federation/tests/utils/test_diaspora.py index 6c05fa3..35d4876 100644 --- a/federation/tests/utils/test_diaspora.py +++ b/federation/tests/utils/test_diaspora.py @@ -44,6 +44,7 @@ def test_get_fetch_content_endpoint(): def test_parse_diaspora_uri(): assert parse_diaspora_uri("diaspora://user@example.com/spam/eggs") == ("user@example.com", "spam", "eggs") + assert parse_diaspora_uri("diaspora://user@example.com/spam/") == ("user@example.com", "spam", "") assert parse_diaspora_uri("diaspora://user@example.com/spam/eggs@spam") == ("user@example.com", "spam", "eggs@spam") assert not parse_diaspora_uri("https://user@example.com/spam/eggs") assert not parse_diaspora_uri("spam and eggs") @@ -57,6 +58,7 @@ def test_parse_profile_diaspora_id(): def test_generate_diaspora_profile_id(): assert generate_diaspora_profile_id("foobar@example.com", "1234") == "diaspora://foobar@example.com/profile/1234" + assert generate_diaspora_profile_id("foobar@example.com") == "diaspora://foobar@example.com/profile/" class TestRetrieveDiasporaHCard: diff --git a/federation/utils/diaspora.py b/federation/utils/diaspora.py index 70071c0..397546e 100644 --- a/federation/utils/diaspora.py +++ b/federation/utils/diaspora.py @@ -163,11 +163,14 @@ def parse_profile_diaspora_id(id): return handle, guid -def generate_diaspora_profile_id(handle, guid): +def generate_diaspora_profile_id(handle, guid=None): """ Generate a Diaspora profile ID from handle and guid. + + Sometimes we don't know the guid if we just have a handle, but still we want to store it + in URI format. """ - return "diaspora://%s/profile/%s" % (handle, guid) + return "diaspora://%s/profile/%s" % (handle, guid or "") def parse_profile_from_hcard(hcard, handle):