On Sat, 16 Jun 2007 18:16:10 +0200, "Mathias Dahl" mathias.dahl@gmail.com wrote:
I am encoding file names using the url-encode function in Hunchentoot. However, it encodes chars such as space and / as well, which makes at least my browser (Firefox) or web server not understand that they are indeed links to files I have shared.
This question actually has nothing to do with Hunchentoot but with understanding what URL-encoding is. See for example:
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
Forward slashes, for example, have special meaning in URLs and thus /must/ be encoded. And the spaces won't confuse Firefox.
What you probably want is (something similar) to this (untested):
(defun foo (pathspec) (format nil "~{~A/~}~A" (mapcar #'url-encode (rest (pathname-directory pathspec))) (url-encode (file-namestring pathspec))))
HTH, Edi.