Revert "Http: do not use escaped Query, because it will break templating (#14146)"
This reverts commit 4f888064d7.
This commit is contained in:
parent
59fafccb90
commit
20afad336b
2 changed files with 7 additions and 9 deletions
|
|
@ -42,9 +42,7 @@ func DefaultScheme(uri, scheme string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not use escaped Query, because it will break templating
|
return u.String()
|
||||||
res, _ := url.QueryUnescape(u.String())
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalIPs returns a slice of local IPv4 addresses
|
// LocalIPs returns a slice of local IPv4 addresses
|
||||||
|
|
|
||||||
|
|
@ -18,23 +18,23 @@ func TestDefaultPort(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultScheme(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)
|
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)
|
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)
|
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)
|
t.Errorf("expected %s, got %s", expect, uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue