commit: da0ef154a6ea87abbe81a094c444546a3e62c723
parent 9fbf01f7a928465406335034b23c10605aa2189a
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date: Sun, 30 Oct 2022 00:38:21 +0000
Merge branch 'from/upstream-develop/tusooa/2930-get-or-fetch' into 'develop'
Fix User.get_or_fetch/1 with usernames starting with http
Closes #2930
See merge request pleroma/pleroma!3751
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
@@ -2126,7 +2126,8 @@ defmodule Pleroma.User do
@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
@@ -850,6 +850,13 @@ defmodule Pleroma.UserTest 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 "fetching a user from nickname or trying to build one" do