Skip to content

Commit

Permalink
feat: support windows paths in embedded templates FS
Browse files Browse the repository at this point in the history
  • Loading branch information
lkingland committed May 7, 2021
1 parent acc56b0 commit c2b2168
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tarfs/tarfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"io"
"io/fs"
"os"
"path"
"sort"
"strings"
Expand Down Expand Up @@ -71,20 +72,20 @@ func (fsys FS) Open(name string) (fs.File, error) {
if name == "." {
elem = "."
for fname, f := range fsys {
i := strings.Index(fname, "/")
i := strings.Index(fname, string(os.PathSeparator))
if i < 0 {
list = append(list, fileInfo{fname, f})
} else {
need[fname[:i]] = true
}
}
} else {
elem = name[strings.LastIndex(name, "/")+1:]
prefix := name + "/"
elem = name[strings.LastIndex(name, string(os.PathSeparator))+1:]
prefix := name + string(os.PathSeparator)
for fname, f := range fsys {
if strings.HasPrefix(fname, prefix) {
felem := fname[len(prefix):]
i := strings.Index(felem, "/")
i := strings.Index(felem, string(os.PathSeparator))
if i < 0 {
list = append(list, fileInfo{felem, f})
} else {
Expand Down

0 comments on commit c2b2168

Please sign in to comment.