]> git.lizzy.rs Git - micro.git/blobdiff - runtime/runtime.go
normalize path - force slash separator to access embed FS (#2197)
[micro.git] / runtime / runtime.go
index c71124cd87c784bf7dcde362022a3b8bd5c0e0ef..5dc46a67eb70fb4a4f87d5f7ec6e63584d972ab4 100644 (file)
@@ -2,6 +2,7 @@ package config
 
 import (
        "embed"
+       "path/filepath"
        "strings"
 )
 
@@ -10,9 +11,13 @@ import (
 //go:embed colorschemes help plugins syntax
 var runtime embed.FS
 
+func fixPath(name string) string {
+       return strings.TrimLeft(filepath.ToSlash(name), "runtime/")
+}
+
 // AssetDir lists file names in folder
 func AssetDir(name string) ([]string, error) {
-       name = strings.TrimLeft(name, "runtime/")
+       name = fixPath(name)
        entries, err := runtime.ReadDir(name)
        if err != nil {
                return nil, err
@@ -26,6 +31,6 @@ func AssetDir(name string) ([]string, error) {
 
 // Asset returns a file content
 func Asset(name string) ([]byte, error) {
-       name = strings.TrimLeft(name, "runtime/")
+       name = fixPath(name)
        return runtime.ReadFile(name)
 }