Dan Cuddeford wrote:
> Wow - thanks for the answer mate!
There's also the Addressable Gem: <http://Addressable.RubyForge.Org/>.
It's intended as a standards compliant replacement for the stdlib's
URI library. Take a look into the test directory of that sucker: over
440 Unit Tests (actually, Object Examples) for a frickin' URI parser!
(See: <http://Addressable.RubyForge.Org/specdoc/>) That guy is nuts!
That code's gotta be as rock-solid as it gets.
Oh, and back to the topic at hand: it has a normalize method built in:
begin
require 'rubygems'
gem 'addressable'
rescue LoadError; end
require 'addressable/uri'
uri = Addressable::URI.heuristic_parse('www.Ruby-Lang..ORG/ARSE/done/../../r e a r/./end/.#exit')
uri.normalize!
puts uri.display_uri # => http://www.ruby-lang..org/r%20e%20a%20r/end/#exit
jwm