Merge pull request #2305 from copperlib/master

fix web static file path slash error for win platform
This commit is contained in:
Márk Sági-Kazár 2021-11-09 12:03:42 +01:00 committed by GitHub
commit 21a8ac6d3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"path/filepath"
"sort" "sort"
"strings" "strings"
@ -109,7 +108,7 @@ func loadWebConfig(c webConfig) (http.Handler, http.Handler, *templates, error)
if err != nil { if err != nil {
return nil, nil, nil, fmt.Errorf("read static dir: %v", err) return nil, nil, nil, fmt.Errorf("read static dir: %v", err)
} }
themeFiles, err := fs.Sub(c.webFS, filepath.Join("themes", c.theme)) themeFiles, err := fs.Sub(c.webFS, path.Join("themes", c.theme))
if err != nil { if err != nil {
return nil, nil, nil, fmt.Errorf("read themes dir: %v", err) return nil, nil, nil, fmt.Errorf("read themes dir: %v", err)
} }
@ -133,7 +132,7 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
if file.IsDir() { if file.IsDir() {
continue continue
} }
filenames = append(filenames, filepath.Join(templatesDir, file.Name())) filenames = append(filenames, path.Join(templatesDir, file.Name()))
} }
if len(filenames) == 0 { if len(filenames) == 0 {
return nil, fmt.Errorf("no files in template dir %q", templatesDir) return nil, fmt.Errorf("no files in template dir %q", templatesDir)