Skip to content

Commit edde1e1

Browse files
committed
Revert "Dont add "/" to path when walking windows os"
This reverts commit 65194a7.
1 parent c781a17 commit edde1e1

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

internal/vfs/internal/internal.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ func (vfs *Common) WalkDir(root string, walkFn fs.WalkDirFunc) error {
132132
if path == "." {
133133
path = ""
134134
}
135-
walkPath := rootName + path
136-
if rest, ok := strings.CutPrefix(walkPath, "/"); ok && tspath.PathIsAbsolute(rest) {
137-
walkPath = rest
138-
}
139-
return walkFn(walkPath, d, err)
135+
return walkFn(rootName+path, d, err)
140136
})
141137
}
142138

internal/vfs/vfstest/vfstest_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -332,20 +332,6 @@ func TestFromMap(t *testing.T) {
332332
content, ok = fs.ReadFile("/mapfile")
333333
assert.Assert(t, ok)
334334
assert.Equal(t, content, "hello, world")
335-
336-
var files []string
337-
err := fs.WalkDir("/", func(path string, d vfs.DirEntry, err error) error {
338-
if err != nil {
339-
return err
340-
}
341-
if !d.IsDir() {
342-
files = append(files, path)
343-
}
344-
return nil
345-
})
346-
assert.NilError(t, err)
347-
slices.Sort(files)
348-
assert.DeepEqual(t, files, []string{"/bytes", "/mapfile", "/string"})
349335
})
350336

351337
t.Run("Windows", func(t *testing.T) {
@@ -370,20 +356,6 @@ func TestFromMap(t *testing.T) {
370356
content, ok = fs.ReadFile("e:/mapfile")
371357
assert.Assert(t, ok)
372358
assert.Equal(t, content, "hello, world")
373-
374-
var files []string
375-
err := fs.WalkDir("/", func(path string, d vfs.DirEntry, err error) error {
376-
if err != nil {
377-
return err
378-
}
379-
if !d.IsDir() {
380-
files = append(files, path)
381-
}
382-
return nil
383-
})
384-
assert.NilError(t, err)
385-
slices.Sort(files)
386-
assert.DeepEqual(t, files, []string{"c:/string", "d:/bytes", "e:/mapfile"})
387359
})
388360

389361
t.Run("Mixed", func(t *testing.T) {

0 commit comments

Comments
 (0)