1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-11-19 03:19:17 +00:00

RelMe.maybe_put_rel_me/2: When true put "me" otherwise nil

This commit is contained in:
Haelwenn (lanodan) Monnier 2019-03-02 06:58:42 +01:00
parent 39a5bea9b7
commit 8e6f7fdb86
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 7 additions and 6 deletions

View file

@ -40,12 +40,12 @@ def maybe_put_rel_me("http" <> _ = target_page, profile_urls) when is_list(profi
true = Enum.any?(rel_me_hrefs, fn x -> x in profile_urls end)
"rel=\"me\" "
"me"
rescue
_ -> ""
_ -> nil
end
def maybe_put_rel_me(_, _) do
""
nil
end
end

View file

@ -37,13 +37,14 @@ test "parse/1" do
test "maybe_put_rel_me/2" do
profile_urls = ["https://social.example.org/users/lain"]
attr = "rel=\"me\" "
attr = "me"
fallback = nil
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/null", profile_urls) ==
""
fallback
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/error", profile_urls) ==
""
fallback
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
attr