Skip to content

Instantly share code, notes, and snippets.

@jtackett
Created April 16, 2015 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtackett/962cddfb89e0b4fe9327 to your computer and use it in GitHub Desktop.
Save jtackett/962cddfb89e0b4fe9327 to your computer and use it in GitHub Desktop.
(defn encode-url-param [v]
(-> v
(str/replace " " "_0")
(str/replace "-" "_1")
(str/replace "&" "_2")
(str/replace "'" "_3")
(str/replace "," "_4")
(clojure.string/escape
{\[ "_5"
\] "_6"
\( "_7"
\) "_8"})))
(defn decode-url-param [v]
(-> v
(str/replace "_0" " ")
(str/replace "_1" "-")
(str/replace "_2" "&")
(str/replace "_3" "'")
(str/replace "_4" ",")
(str/replace "_5" "[")
(str/replace "_6" "]")
(str/replace "_7" "(")
(str/replace "_8" ")")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment