Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

andydotxyz
Copy link
Member

Fix up docs to clarify as well.

Fixes #5234

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@coveralls
Copy link

coveralls commented Nov 6, 2024

Coverage Status

coverage: 59.958%. remained the same
when pulling f7de701 on andydotxyz:fix/5234
into 85063d5 on fyne-io:develop.

@steampoweredtaco
Copy link
Contributor

Thanks for fixing the bug, LGTM. The added documentation is exactly what I was asking for as well.

Copy link
Member

@Jacalz Jacalz left a 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] != '/' {
Copy link
Member

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)]
Copy link
Member

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
Copy link
Member

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()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants