diff --git a/pkg/camo/proxy.go b/pkg/camo/proxy.go index c6de6b2..b967368 100644 --- a/pkg/camo/proxy.go +++ b/pkg/camo/proxy.go @@ -90,7 +90,8 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) { // split path and get components components := strings.Split(req.URL.Path, "/") - if len(components) < 3 { + compLen := len(components) + if compLen < 3 { http.Error(w, "Malformed request path", http.StatusNotFound) return } @@ -102,7 +103,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) { } encodedExtraHdr := "" - if p.config.EnableExtraHeaders && len(components) == 4 { + if p.config.EnableExtraHeaders && compLen == 4 { encodedExtraHdr = components[3] } diff --git a/pkg/router/router.go b/pkg/router/router.go index 9feeb9f..fd36800 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -47,8 +47,7 @@ func (dr *DumbRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - components := strings.Split(r.URL.Path, "/") - compLen := len(components) + compLen := strings.Count(r.URL.Path, "/") if compLen == 3 || compLen == 4 { dr.CamoHandler.ServeHTTP(w, r) return