Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 19:26:09 +01:00

Fix filepath basename on Windows for SVG bindata (#12241)

This commit is contained in:
Cirno the Strongest 2020-07-13 22:16:40 +02:00 committed by GitHub
parent 84a419de98
commit 633f52c220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -7,7 +7,6 @@
package svg package svg
import ( import (
"path"
"path/filepath" "path/filepath"
"code.gitea.io/gitea/modules/public" "code.gitea.io/gitea/modules/public"
@ -22,7 +21,7 @@ func Discover() map[string]string {
if matched { if matched {
content, err := public.Asset(file) content, err := public.Asset(file)
if err == nil { if err == nil {
filename := path.Base(file) filename := filepath.Base(file)
svgs[filename[:len(filename)-4]] = string(content) svgs[filename[:len(filename)-4]] = string(content)
} }
} }

View file

@ -8,7 +8,6 @@ package svg
import ( import (
"io/ioutil" "io/ioutil"
"path"
"path/filepath" "path/filepath"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
@ -18,11 +17,11 @@ import (
func Discover() map[string]string { func Discover() map[string]string {
svgs := make(map[string]string) svgs := make(map[string]string)
files, _ := filepath.Glob(path.Join(setting.StaticRootPath, "public", "img", "svg", "*.svg")) files, _ := filepath.Glob(filepath.Join(setting.StaticRootPath, "public", "img", "svg", "*.svg"))
for _, file := range files { for _, file := range files {
content, err := ioutil.ReadFile(file) content, err := ioutil.ReadFile(file)
if err == nil { if err == nil {
filename := path.Base(file) filename := filepath.Base(file)
svgs[filename[:len(filename)-4]] = string(content) svgs[filename[:len(filename)-4]] = string(content)
} }
} }