@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