Skip to content

Commit

Permalink
simplify fileserver path cleaning
Browse files Browse the repository at this point in the history
fix typo
  • Loading branch information
fschade committed Feb 23, 2022
1 parent 07f6913 commit f9c976a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/enhancement-web-spa-fileserver.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Enhancement: Add SPA conform fileserver fow web
Enhancement: Add SPA conform fileserver for web

We've added an SPA conform fileserver to the web service.
It enables web to use vue's history mode and behaves like nginx try_files.
Expand Down
9 changes: 2 additions & 7 deletions web/pkg/assets/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"path"
"path/filepath"
"strings"
)

type fileServer struct {
Expand All @@ -20,12 +19,8 @@ func FileServer(root http.FileSystem) http.Handler {
}

func (f *fileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
upath := r.URL.Path
if !strings.HasPrefix(upath, "/") {
upath = "/" + upath
r.URL.Path = upath
}
upath = path.Clean(upath)
upath := path.Clean(path.Join("/", r.URL.Path))
r.URL.Path = upath

asset, err := f.root.Open(upath)
if err != nil {
Expand Down

0 comments on commit f9c976a

Please sign in to comment.