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

as_icon should have a uniform url getter #85

Closed
hsitter opened this issue Oct 31, 2016 · 1 comment
Closed

as_icon should have a uniform url getter #85

hsitter opened this issue Oct 31, 2016 · 1 comment

Comments

@hsitter
Copy link
Contributor

hsitter commented Oct 31, 2016

as_icon currently forces a differentiation on the API user with regards to whether an icon is local or remote. Chances are the API user won't care if her language/framework can handle all possible URI schemes including file://.

There should be a way to enable convenient uniform URL handling regardless of whether a file is local or remote, possibly by making as_icon_get_url always return something.

Assuming the API user can understand file:// this allows the user to only use a single function without branching. Right now one always needs to special case local files and check as_icon_get_filename as well as as_icon_get_url, even when one could just handle them all the same.

e.g. in Ruby I need the following to open an icon resource

icon = component.icons.index(0)
open(icon.filename ? icon.filename : icon.url)
# NB: without ternary this would be between 4 and 5 lines (or more... think Go ;))

same code with uniform getter

open(component.icons.index(0).url) # Could be file://var/yolo/whatever.png
@ximion
Copy link
Owner

ximion commented Oct 31, 2016

Actually, get_url should return a file URL in that case already. I will look into it.

@ximion ximion closed this as completed in 88a66c5 Oct 31, 2016
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

No branches or pull requests

2 participants