URI encode and param lost

Hi,
I have an url: http://foo.com/posts?id=30&limit=éé#time=1305298413
I am using uri class to parse it: URI::split(url)
the problem is I need to encode it: URI.encode(url) first, which it
gives
http://foo.com/posts?id=30&limit=éé%23time=1305298413
but with encoding it the fragment is lost and I can’t
perform the split function

Can anyone help me to solve this problem
regards,

On Sun, Jun 10, 2012 at 12:24 AM, rubix Rubix [email protected]
wrote:

regards,
The issue is that your original URI is not a valid URI since it
contains characters which are not allowed in the URI. Basically you
need to encode parameters before you put them in the URI to make it
a valid URI and have URI.split work successfully:

irb(main):044:0> u = URI.parse ‘http://foo.com/posts
=> #<URI::HTTP:0x956a280 URL:http://foo.com/posts>
irb(main):045:0> u.query =
{id:30,limit:‘’}.map{|k,v|“#{k}=#{URI.encode(v.to_s)}”}.join ‘&’
=> “id=30&limit=%C3%A9%C3%A9”
irb(main):046:0> u.fragment=‘time=1305298413’
=> “time=1305298413”
irb(main):047:0> u
=> #<URI::HTTP:0x956a280
URL:http://foo.com/posts?id=30&limit=éé#time=1305298413>
irb(main):048:0> puts u
http://foo.com/posts?id=30&limit=éé#time=1305298413
=> nil

Kind regards

robert