fix(http): treat an empty proxy_url as no proxy

This commit is contained in:
Lain Soykaf 2026-10-24 14:12:47 +04:00
commit 1c8c6048de
No known key found for this signature in database
4 changed files with 17 additions and 2 deletions

View file

@ -58,6 +58,13 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
{:socks5, ~c"::1", 9050}
end
# AdminFE stores an empty field as "", and Hackney 4 fails every request with it.
test "ignores an empty proxy_url", %{uri: uri} do
clear_config([:http, :proxy_url], "")
refute Keyword.has_key?(Hackney.options([], uri), :proxy)
end
test "respect connection opts and no proxy", %{uri: uri} do
opts = Hackney.options([a: 2, b: 1], uri)

View file

@ -12,6 +12,12 @@ defmodule Pleroma.HTTP.AdapterHelperTest do
assert AdapterHelper.format_proxy(nil) == nil
end
test "with an empty string" do
assert ExUnit.CaptureLog.capture_log(fn ->
assert AdapterHelper.format_proxy("") == nil
end) == ""
end
test "with string" do
assert AdapterHelper.format_proxy("127.0.0.1:8123") == {{127, 0, 0, 1}, 8123}
end