Match basepath against regexp to ensure proper format

pull/10616/head
Jared Scheib 2018-04-20 11:39:42 -07:00
parent 923d73a418
commit 094f96a73b
1 changed files with 4 additions and 3 deletions

View File

@ -11,9 +11,9 @@ import (
"net/url"
"os"
"path"
"regexp"
"runtime"
"strconv"
"strings"
"time"
"github.com/influxdata/chronograf"
@ -346,8 +346,9 @@ func (s *Server) Serve(ctx context.Context) error {
return err
}
if strings.HasPrefix(s.Basepath, "/") {
err := fmt.Errorf("Basepath must begin with '/'")
re := regexp.MustCompile(`(\/{1}\w+)+`)
if len(re.ReplaceAllLiteralString(s.Basepath, "")) > 0 {
err := fmt.Errorf("Invalid basepath, must follow format \"/mybasepath\"")
logger.
WithField("component", "server").
WithField("basepath", "invalid").