Closed yogthos closed 11 years ago
I think throwing an exception in the case of a bad image source is the right approach. Silently fixing the mistakes of developers can only lead to bad things.
I guess the way I was looking at it is that you have a valid file name relative to the system path, so url encoding is something that would be handled. Might be worth documenting in the API that src has to be url encoded, and not simply a valid path relative to the fs.
It may be a valid file name, but it's not a valid URI, and the src attribute of an image tag takes the latter.
Perhaps an assertion on the image function might be useful, but I'm not sure it's really Hiccup's job to inform the user when they're writing bad HTML.
Helpful errors are always good in my experience. I'd advocate for the assert myself, but it's your call obviously. :)
for example if you have an image link with a filename 12 - 2.jpg
this will work correctly
but using
image
does notbecause
to-url
will throw an exception parsing the string