Skip to content

Commit 700634a

Browse files
committed
fix windows path handling
1 parent afca0b2 commit 700634a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

echo.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ type defaultFS struct {
804804
func NewDefaultFS(dir string) fs.FS {
805805
return &defaultFS{
806806
prefix: dir,
807-
fs: os.DirFS(filepath.ToSlash(filepath.Clean(dir))),
807+
fs: os.DirFS(dir),
808808
}
809809
}
810810

@@ -814,10 +814,9 @@ func (fs defaultFS) Open(name string) (fs.File, error) {
814814
// a file with an absolute path we need to remove prefix and then call fs.FS.Open().
815815
// not to force users to cut prefix from file name we do it here.
816816
if filepath.IsAbs(name) {
817-
name = filepath.ToSlash(filepath.Clean(name))
818817
if strings.HasPrefix(name, fs.prefix) {
819818
name = name[len(fs.prefix):]
820-
if len(name) > 1 && name[0] == '/' {
819+
if len(name) > 1 && os.IsPathSeparator(name[0]) {
821820
name = name[1:]
822821
}
823822
}

0 commit comments

Comments
 (0)