-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update NewFileURI to support relative paths #5243
base: develop
Are you sure you want to change the base?
Conversation
…rip up when the URI is used on a different system
Thanks for fixing the bug, LGTM. The added documentation is exactly what I was asking for as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Just a few comments inline :)
if parent[len(parent)-1] != filepath.Separator { | ||
child := filepath.Base(s) | ||
parent := s[:len(s)-len(child)] | ||
if parent[len(parent)-1] != '/' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already a problem before this change obviously but will this not do parent[-1]
if parent is empty? Maybe that can't ever happen but I just got a bit worried when seeing it now :)
parent = filepath.Dir(s) | ||
if parent[len(parent)-1] != filepath.Separator { | ||
child := filepath.Base(s) | ||
parent := s[:len(s)-len(child)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there something wrong with filepath.Dir
? If so, this might warrant a comment as to why we are hard coding the logic.
func NewFileURI(path string) fyne.URI { | ||
assumeAbs := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using filepath.IsAbs()
?
Fix up docs to clarify as well.
Fixes #5234
Checklist: