Skip to content

Commit

Permalink
trim path
Browse files Browse the repository at this point in the history
  • Loading branch information
atterpac committed Jul 21, 2024
1 parent 56023de commit bb3e2e8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions v3/internal/assetserver/assetserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,23 @@ func (a *AssetServer) serveHTTP(rw http.ResponseWriter, req *http.Request, userH
}

default:

// Check if this is a plugin asset
if !strings.HasPrefix(reqPath, servicePrefix) {
userHandler.ServeHTTP(rw, req)
return
}

// Ensure there is at least 3 parts to the reqPath /<services>/<service>/<path>
parts := strings.SplitN(reqPath, "/", 3)
// Ensure there is at least 3 parts to the reqPath /services/<service>/<path>
parts := strings.Split(reqPath, "/")
if len(parts) < 3 {
rw.WriteHeader(http.StatusNotFound)
return
}


// Check if this is a registered plugin asset
if handler, ok := a.services[parts[2]]; ok {
// Check if the file exists
// Trim the service preifx
req.URL.Path = strings.Join(parts[3:], "/")
handler.ServeHTTP(rw, req)
} else {
userHandler.ServeHTTP(rw, req)
Expand Down

0 comments on commit bb3e2e8

Please sign in to comment.