Use the Addressable gem for URI parsing.  (It handle special characters, etc. better.)