Use strings.TrimPrefix to make sure relative url doesn't start with forward slash

Closes grafana/grafana#10263
This commit is contained in:
SteelPhase 2017-12-18 13:52:42 -05:00 committed by Bajumpaa, Eric T
parent dd2192cccc
commit a320a83138

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"strconv" "strconv"
"strings"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
@ -41,7 +42,7 @@ func OrgRedirect() macaron.Handler {
return return
} }
newUrl := setting.ToAbsUrl(fmt.Sprintf("%s?%s", c.Req.URL.Path, c.Req.URL.Query().Encode())) newURL := setting.ToAbsUrl(fmt.Sprintf("%s?%s", strings.TrimPrefix(c.Req.URL.Path, "/"), c.Req.URL.Query().Encode()))
c.Redirect(newUrl, 302) c.Redirect(newURL, 302)
} }
} }