fix(proxy): check for trailing slash on listen.prefix when proxy is on

When constructing proxy path to listen on for requests to pass upstream check if listen.prefix ends with / and if no inject it.

Fixes #386
This commit is contained in:
Łukasz Mierzwa
2019-01-30 15:36:49 +00:00
parent 1ae5503e11
commit b93641af93

View File

@@ -15,7 +15,11 @@ import (
)
func proxyPathPrefix(name string) string {
return fmt.Sprintf("%sproxy/alertmanager/%s", config.Config.Listen.Prefix, name)
maybeSlash := ""
if !strings.HasSuffix(config.Config.Listen.Prefix, "/") {
maybeSlash = "/"
}
return fmt.Sprintf("%s%sproxy/alertmanager/%s", config.Config.Listen.Prefix, maybeSlash, name)
}
func proxyPath(name, path string) string {