diff --git a/app/vmauth/target_url.go b/app/vmauth/target_url.go index 5e5d81f56f..2e8817f8d7 100644 --- a/app/vmauth/target_url.go +++ b/app/vmauth/target_url.go @@ -42,6 +42,7 @@ func createTargetURL(ui *UserInfo, uOrig *url.URL) (*url.URL, error) { if !strings.HasPrefix(u.Path, "/") { u.Path = "/" + u.Path } + u.Path = strings.TrimSuffix(u.Path, "/") for _, e := range ui.URLMap { for _, sp := range e.SrcPaths { if sp.match(u.Path) { diff --git a/app/vmauth/target_url_test.go b/app/vmauth/target_url_test.go index 18d7e53613..e037bd783f 100644 --- a/app/vmauth/target_url_test.go +++ b/app/vmauth/target_url_test.go @@ -26,7 +26,10 @@ func TestCreateTargetURLSuccess(t *testing.T) { }, "", "http://foo.bar/.") f(&UserInfo{ URLPrefix: mustParseURL("http://foo.bar"), - }, "/", "http://foo.bar/") + }, "/", "http://foo.bar") + f(&UserInfo{ + URLPrefix: mustParseURL("http://foo.bar/federate"), + }, "/", "http://foo.bar/federate") f(&UserInfo{ URLPrefix: mustParseURL("http://foo.bar"), }, "a/b?c=d", "http://foo.bar/a/b?c=d")