From 2aa8e66527fd763b59c1592e53c25d3eaf28f7f0 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Thu, 8 Sep 2022 11:58:17 -0400 Subject: [PATCH] Fix User.get_or_fetch/1 with usernames starting with http --- lib/pleroma/user.ex | 3 ++- test/pleroma/user_test.exs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 138f3c851..a36c1c330 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1988,7 +1988,8 @@ def ap_enabled?(_), do: false @doc "Gets or fetch a user by uri or nickname." @spec get_or_fetch(String.t()) :: {:ok, User.t()} | {:error, String.t()} - def get_or_fetch("http" <> _host = uri), do: get_or_fetch_by_ap_id(uri) + def get_or_fetch("http://" <> _host = uri), do: get_or_fetch_by_ap_id(uri) + def get_or_fetch("https://" <> _host = uri), do: get_or_fetch_by_ap_id(uri) def get_or_fetch(nickname), do: get_or_fetch_by_nickname(nickname) # wait a period of time and return newest version of the User structs diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 9d35f9780..0272e3142 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -737,6 +737,13 @@ test "gets an existing user by ap_id" do freshed_user = refresh_record(user) assert freshed_user == fetched_user end + + test "gets an existing user by nickname starting with http" do + user = insert(:user, nickname: "httpssome") + {:ok, fetched_user} = User.get_or_fetch("httpssome") + + assert user == fetched_user + end end describe "get_or_fetch/1 remote users with tld, while BE is runned on subdomain" do