on URI Ruby escaping
February 3rd, 2008
URI.escape method with no options doesn’t provide a trully good escape, and i just noticed it upon the need to access an API.
url = 'http://www.ruby-lang.org'
bad = URI.escape(url)
good = URI.escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
The difference is:
bad => "http://www.ruby-lang.org"
good => "http%3A%2F%2Fwww.ruby-lang.org"
(via snippets.dzone => Matt Zukowski)