I have a string that contains an escaped URL:
http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz
I'm trying to decode it to the following:
http://example.com?foo=bar+baz
However, I can't find any suitable function exported by Drakma. I can encode like so:
* url-string
"http://example.com?foo=bar+baz"
* (drakma:url-encode url-string :utf-8)
"http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz"
... so I figure I'm on the right track. If anyone could supply a nudge in the right direction I'd appreciate it :-) I'm using SBCL 1.0.54, built from source on 64-bit Linux Mint 13.
If it helps clarify what I'm trying to do, in Ruby, I'd do the following:
> uri_string = "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
=> "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
> URI.decode uri_string
=> "http://example.com?foo=bar+baz"
A quick SLIME session.
CL-USER> (ql-dist:system-apropos "url")
#<SYSTEM curly / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM curly.test / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM do-urlencode / do-urlencode-20120407-git / quicklisp 2012-05-20>
#<SYSTEM url-rewrite / url-rewrite-0.1.1 / quicklisp 2012-05-20>
CL-USER> (ql:quickload :do-urlencode)
C-cC-dpdo-urlencode
RET
DO-URLENCODE:URLDECODE
Function: (not documented)
DO-URLENCODE:URLENCODE
Function: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING
Type: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING-STRING
Generic Function: (not documented)
CL-USER> (do-urlencode:urldecode "http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz")
"http://example.com?foo=bar+baz"