Add additional filepath.ToSlash()

`filepath.Join()` also converts slashes to local filesystem separators. It doesn't work properly for embed.FS
This commit is contained in:
Paweł Kierski 2023-04-10 20:45:28 +02:00 committed by GitHub
parent 564e41eaff
commit 0e61e22b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ func (h *uiAssetsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (h *uiAssetsHandler) indexFilePath() string {
return filepath.Join(h.staticDirPath, h.indexFileName)
return filepath.ToSlash(filepath.Join(h.staticDirPath, h.indexFileName))
}
func (h *uiAssetsHandler) renderIndexFile(w http.ResponseWriter) error {
@ -81,7 +81,7 @@ func (h *uiAssetsHandler) serveFile(w http.ResponseWriter, path string) (code in
}
return http.StatusOK, nil
}
path = filepath.Join(h.staticDirPath, path)
path = filepath.ToSlash(filepath.Join(h.staticDirPath, path))
bytes, err := h.contents.ReadFile(path)
if err != nil {
// If path is error (e.g. file not exist, path is a directory), serve index file.