Match basepath against regexp to ensure proper format
parent
923d73a418
commit
094f96a73b
|
@ -11,9 +11,9 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/chronograf"
|
"github.com/influxdata/chronograf"
|
||||||
|
@ -346,8 +346,9 @@ func (s *Server) Serve(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(s.Basepath, "/") {
|
re := regexp.MustCompile(`(\/{1}\w+)+`)
|
||||||
err := fmt.Errorf("Basepath must begin with '/'")
|
if len(re.ReplaceAllLiteralString(s.Basepath, "")) > 0 {
|
||||||
|
err := fmt.Errorf("Invalid basepath, must follow format \"/mybasepath\"")
|
||||||
logger.
|
logger.
|
||||||
WithField("component", "server").
|
WithField("component", "server").
|
||||||
WithField("basepath", "invalid").
|
WithField("basepath", "invalid").
|
||||||
|
|
Loading…
Reference in New Issue