From 20afad336be563de9653eab13a0e23d1f0af8f0c Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 4 Jun 2024 16:14:58 +0200 Subject: [PATCH] Revert "Http: do not use escaped Query, because it will break templating (#14146)" This reverts commit 4f888064d7396ccecddc9761bb6b752048450c37. --- util/net.go | 4 +--- util/net_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/util/net.go b/util/net.go index 777b67c2ca..cfe6b3d189 100644 --- a/util/net.go +++ b/util/net.go @@ -42,9 +42,7 @@ func DefaultScheme(uri, scheme string) string { } } - // do not use escaped Query, because it will break templating - res, _ := url.QueryUnescape(u.String()) - return res + return u.String() } // LocalIPs returns a slice of local IPv4 addresses diff --git a/util/net_test.go b/util/net_test.go index a46fec79b1..9f9f691c62 100644 --- a/util/net_test.go +++ b/util/net_test.go @@ -18,23 +18,23 @@ func TestDefaultPort(t *testing.T) { } func TestDefaultScheme(t *testing.T) { - expect := "http://localhost/a={{b}}?a={{b}}" + expect := "http://localhost" - if uri := DefaultScheme("localhost/a={{b}}?a={{b}}", "http"); uri != expect { + if uri := DefaultScheme("localhost", "http"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - if uri := DefaultScheme("http://localhost/a={{b}}?a={{b}}", "http"); uri != expect { + if uri := DefaultScheme("http://localhost", "http"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - if uri := DefaultScheme("http://localhost/a={{b}}?a={{b}}", "https"); uri != expect { + if uri := DefaultScheme("http://localhost", "https"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - expect = "ws://localhost:8080/a={{b}}?a={{b}}" + expect = "ws://localhost:8080" - if uri := DefaultScheme("localhost:8080/a={{b}}?a={{b}}", "ws"); uri != expect { + if uri := DefaultScheme("localhost:8080", "ws"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } }