mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-23 16:07:54 -04:00
Properly handle path-only addresses (also fix godoc typos)
This commit is contained in:
@@ -273,12 +273,12 @@ func (a Address) VHost() string {
|
||||
}
|
||||
|
||||
// standardizeAddress parses an address string into a structured format with separate
|
||||
// scheme, host, and port portions, as well as the original input string.
|
||||
// scheme, host, port, and path portions, as well as the original input string.
|
||||
func standardizeAddress(str string) (Address, error) {
|
||||
input := str
|
||||
|
||||
// Split input into components (prepend with // to assert host by default)
|
||||
if !strings.Contains(str, "//") {
|
||||
if !strings.Contains(str, "//") && !strings.HasPrefix(str, "/") {
|
||||
str = "//" + str
|
||||
}
|
||||
u, err := url.Parse(str)
|
||||
|
||||
@@ -50,6 +50,7 @@ func TestStandardizeAddress(t *testing.T) {
|
||||
{`https://host:443/path/foo`, "https", "host", "443", "/path/foo", false},
|
||||
{`host:80/path`, "", "host", "80", "/path", false},
|
||||
{`host:https/path`, "https", "host", "443", "/path", false},
|
||||
{`/path`, "", "", "", "/path", false},
|
||||
} {
|
||||
actual, err := standardizeAddress(test.input)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user