Skip to content

Commit

Permalink
Fix support for the absolute path /
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Nov 6, 2024
1 parent 9ca2fbb commit 25cc74c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions storage/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import (
// Relative paths will be converted to absolute using filepath.Abs if required.
func NewFileURI(path string) fyne.URI {
assumeAbs := false
if len(path) >= 2 {
assumeAbs = path[1] == ':' || path[0] == '/'
if len(path) >= 1 {
if path[0] == '/' {
assumeAbs = true
} else if len(path) >= 2 {
assumeAbs = path[1] == ':'
}
}

if !assumeAbs {
Expand Down
2 changes: 2 additions & 0 deletions storage/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ func TestFileAbs(t *testing.T) {

assert.Equal(t, abs.Path(), rel.Path())
assert.Equal(t, abs.String(), rel.String())

assert.Equal(t, "file:///", storage.NewFileURI("/").String())
}

func TestWriteAndDelete(t *testing.T) {
Expand Down

0 comments on commit 25cc74c

Please sign in to comment.