You can use the default Java classes which are available:

=> (-> (java.net.URI. "http" "www.mysite" "/some user" nil) .toURL
.toString)
"http://www.mysite/some%20user";
=>

ring-codec is easy too:

(https://github.com/ring-clojure/ring-codec)

=> (str "www.mysite/" (ring.util.codec/url-encode "some user"))
"www.mysite/some%20user"
=>


(2014/02/25 16:14), David Toomey wrote:
> I'm building a site and I would like to allow users to create and
> account, and I would like them to have an option to use whitespaces in
> their handle. Apparently I am doing something way wrong here, so it is
> possible that I messed up something somewhere else.
> 
> When I create a user, for example "some user", this user name is
> inserted into a database. The site is set up so that users can have
> profiles. This person's profile would be this:
> 
>       www.mysite/some user
> 
> That is bad. I am hoping to have profile pages look like this:
> 
>      www.mysite/some%20user
> 
> or:
> 
>       www.mysite/some-user
> 
> I attempted to use (url-encode), (url-decode), regex, and all sorts of
> things. Nothing I have tried has worked.
> 
> I'm actually kind of surprised that this isn't baked into Compojure
> itself, but I digress.
> 
> Thanks;
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to