]> git.lizzy.rs Git - micro.git/commitdiff
normalize path - force slash separator to access embed FS (#2197)
authorAli Kefia <alikefia@users.noreply.github.com>
Wed, 25 Aug 2021 20:26:54 +0000 (22:26 +0200)
committerGitHub <noreply@github.com>
Wed, 25 Aug 2021 20:26:54 +0000 (16:26 -0400)
.gitignore
runtime/runtime.go

index 62f97acf877bf0544432994cba3d5068d3e46c1f..2adb8d5fd895bf246edfc97c9beca9a6aeb83efe 100644 (file)
@@ -15,6 +15,5 @@ benchmark_results*
 tools/build-version
 tools/build-date
 tools/info-plist
-tools/bindata
 tools/vscode-tests/
 *.hdr
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)
 }