diff --git a/lib/fs/basicfs.go b/lib/fs/basicfs.go index fb9087431..32dd9de06 100644 --- a/lib/fs/basicfs.go +++ b/lib/fs/basicfs.go @@ -30,6 +30,10 @@ type BasicFilesystem struct { } func newBasicFilesystem(root string) *BasicFilesystem { + if root == "" { + root = "." // Otherwise "" becomes "/" below + } + // The reason it's done like this: // C: -> C:\ -> C:\ (issue that this is trying to fix) // C:\somedir -> C:\somedir\ -> C:\somedir diff --git a/lib/fs/basicfs_test.go b/lib/fs/basicfs_test.go index 7c14b6b02..7b23d7883 100644 --- a/lib/fs/basicfs_test.go +++ b/lib/fs/basicfs_test.go @@ -514,6 +514,10 @@ func TestNewBasicFilesystem(t *testing.T) { t.Skip("non-windows root paths") } + currentDir, err := filepath.Abs(".") + if err != nil { + t.Fatal(err) + } testCases := []struct { input string expectedRoot string @@ -521,7 +525,8 @@ func TestNewBasicFilesystem(t *testing.T) { }{ {"/foo/bar/baz", "/foo/bar/baz", "/foo/bar/baz"}, {"/foo/bar/baz/", "/foo/bar/baz", "/foo/bar/baz"}, - {"", "/", "/"}, + {"", currentDir, currentDir}, + {".", currentDir, currentDir}, {"/", "/", "/"}, }