Closed brokensandals closed 12 years ago
You have a point. Perhaps link-to
should not call resolve-uri, but leave that up to url
. It's perhaps better to be explicit in this case.
That would be my vote. (I ran into the same issue with form-to.)
I've fixed this in a way that both link-to
and url
can be used together with base URLs:
(with-base-url "/foo" (html (link-to "/bar" "Bar")))
=> "<a href=\"/foo/bar\">Bar</a>"
(with-base-url "/foo" (html (link-to (url "/bar") "Bar")))
=> "<a href=\"/foo/bar\">Bar</a>"
The one caveat is that with-base-url
needs to be outside the html
form, however, this is often the case.
Because url and link-to both call resolve-uri, code such as (link-to (url "/foo" {...})...) will result in the base URL being prepended twice.
Maybe I'm using the methods in a way they aren't intended? url is very convenient - helpful for generating links as well as redirect locations - and in my (very limited) time using Hiccup, almost every occasion I'm using link-to for a relative path, I also want to use url.