From a1c1076137b1b60dd2edb4407819a02fc3524aa2 Mon Sep 17 00:00:00 2001 From: copperyp Date: Sat, 23 Oct 2021 12:09:05 +0800 Subject: [PATCH 1/2] fix web static file path slash error for win platform Signed-off-by: copperyp --- server/templates.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/templates.go b/server/templates.go index e46855b174..13e3bfc8ce 100644 --- a/server/templates.go +++ b/server/templates.go @@ -109,7 +109,7 @@ func loadWebConfig(c webConfig) (http.Handler, http.Handler, *templates, error) if err != nil { 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, filepath.ToSlash(filepath.Join("themes", c.theme))) if err != nil { return nil, nil, nil, fmt.Errorf("read themes dir: %v", err) } @@ -133,7 +133,7 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) { if file.IsDir() { continue } - filenames = append(filenames, filepath.Join(templatesDir, file.Name())) + filenames = append(filenames, filepath.ToSlash(filepath.Join(templatesDir, file.Name()))) } if len(filenames) == 0 { return nil, fmt.Errorf("no files in template dir %q", templatesDir) From 5854dd192da901a67715ca9ed28d913d7c1d3b51 Mon Sep 17 00:00:00 2001 From: copperyp Date: Wed, 27 Oct 2021 14:40:58 +0800 Subject: [PATCH 2/2] using path.Join replace filepath.Join Signed-off-by: copperyp --- server/templates.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/templates.go b/server/templates.go index 13e3bfc8ce..9be8019a48 100644 --- a/server/templates.go +++ b/server/templates.go @@ -8,7 +8,6 @@ import ( "net/http" "net/url" "path" - "path/filepath" "sort" "strings" @@ -109,7 +108,7 @@ func loadWebConfig(c webConfig) (http.Handler, http.Handler, *templates, error) if err != nil { return nil, nil, nil, fmt.Errorf("read static dir: %v", err) } - themeFiles, err := fs.Sub(c.webFS, filepath.ToSlash(filepath.Join("themes", c.theme))) + themeFiles, err := fs.Sub(c.webFS, path.Join("themes", c.theme)) if err != nil { 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() { continue } - filenames = append(filenames, filepath.ToSlash(filepath.Join(templatesDir, file.Name()))) + filenames = append(filenames, path.Join(templatesDir, file.Name())) } if len(filenames) == 0 { return nil, fmt.Errorf("no files in template dir %q", templatesDir)