wtetzner / exploding-fish

A URI library for Clojure
Other
150 stars 12 forks source link

The param function does not seem to be working with relative URIs. #5

Closed roanosullivan closed 11 years ago

roanosullivan commented 11 years ago

The param function does not seem to be working with relative URIs.

For example, the following function call will result in the results param being duplicated:

=> (require '[org.bovinegenius.exploding-fish :as uri])
nil
=> (uri/param "/orders/2013/Q1?results=2013_Q1_hide_empty.png" "results" "2013_Q1_show_empty.png")
"/orders/2013/Q1?results=2013_Q1_hide_empty.png?results=2013_Q1_show_empty.png"
=> 

My understanding of docs is that the old param value should replaced with the new param value, in which case the above behavior is incorrect.

roanosullivan commented 11 years ago

For what it's worth, URIBuilder in Apache HttpClient works:

=> (import '[org.apache.http.client.utils URIBuilder])
org.apache.http.client.utils.URIBuilder
=> (def src "/orders/2013/Q1?results=2013_Q1_hide_empty.png")
#'oe-metrics-ui.server/src
=> (str (.build (.setParameter (URIBuilder. src) "results" "2013_Q1_show_empty.png")))
"/orders/2013/Q1?results=2013_Q1_show_empty.png"

But I would prefer not to depend on [org.apache.httpcomponents/httpclient "4.2.3"].

wtetzner commented 11 years ago

This should be fixed now in version 0.3.2. The underlying issue is that there was a bug with parsing relative URIs.

roanosullivan commented 11 years ago

Works for me with 0.3.2:

=> (use '[org.bovinegenius.exploding-fish :as uri])
nil
=> (uri/param "/orders/2013/Q1?results=2013_Q1_hide_empty.png" "results" "2013_Q1_show_empty.png")
"/orders/2013/Q1?results=2013_Q1_show_empty.png"

I had been using 0.3.1.

Thanks!