diff --git a/util/net.go b/util/net.go index cfe6b3d18..777b67c2c 100644 --- a/util/net.go +++ b/util/net.go @@ -42,7 +42,9 @@ func DefaultScheme(uri, scheme string) string { } } - return u.String() + // do not use escaped Query, because it will break templating + res, _ := url.QueryUnescape(u.String()) + return res } // LocalIPs returns a slice of local IPv4 addresses diff --git a/util/net_test.go b/util/net_test.go index 9f9f691c6..a46fec79b 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" + expect := "http://localhost/a={{b}}?a={{b}}" - if uri := DefaultScheme("localhost", "http"); uri != expect { + if uri := DefaultScheme("localhost/a={{b}}?a={{b}}", "http"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - if uri := DefaultScheme("http://localhost", "http"); uri != expect { + if uri := DefaultScheme("http://localhost/a={{b}}?a={{b}}", "http"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - if uri := DefaultScheme("http://localhost", "https"); uri != expect { + if uri := DefaultScheme("http://localhost/a={{b}}?a={{b}}", "https"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } - expect = "ws://localhost:8080" + expect = "ws://localhost:8080/a={{b}}?a={{b}}" - if uri := DefaultScheme("localhost:8080", "ws"); uri != expect { + if uri := DefaultScheme("localhost:8080/a={{b}}?a={{b}}", "ws"); uri != expect { t.Errorf("expected %s, got %s", expect, uri) } }