Skip to content

Allow nil query values #14

vincentjames501 opened this Issue Jun 17, 2014 · 2 comments

2 participants


First I'd like to say awesome project! We have a project using Stripes and we are trying to parse a referrer header using cemerick. The issue here is that this is a valid url and should be parsed as such.

(url "http://localhost/icmobile/actions/User.action?listAllPageShow=")
=> IllegalArgumentException No value supplied for key: listAllPageShow

I think we should adjust the internal query->map function as follows:

(defn- augment 
    (if (= 1 (count query-vector))
        [(first query-vector) nil]

(defn- query->map
  (when qstr
    (-?>> (.split qstr "&")
      (mapcat #(.split % "="))
      (map url-decode)
      (apply hash-map))))

such that the output is now:

(url "http://localhost/icmobile/actions/User.action?listAllPageShow=abc")
=> #cemerick.url.URL{:protocol "http", :username nil, :password nil, :host "localhost", :port -1, :path "/icmobile/actions/User.action", :query {"listAllPageShow" "abc"}, :anchor nil}
(url "http://localhost/icmobile/actions/User.action?listAllPageShow=")
=> #cemerick.url.URL{:protocol "http", :username nil, :password nil, :host "localhost", :port -1, :path "/icmobile/actions/User.action", :query {"listAllPageShow" nil}, :anchor nil}

I'm not a Clojure expert which is why I'm not submitting this as a pull request. If you feel this is acceptable, I'd be happy to submit a pull request.


Looks reasonable. PR welcome.


Closing as this looks to be resolved in 0.1.1, I was using an older version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.