If a URI object is passed another URI object when it's expecting a string, it throws an exception. Regardless of whether
this is a good idea, the exception is very unclear.
For example:
require 'uri'
url = 'http://ruby-lang.org/'
URI.parse(URI.parse url)
Trackback:
/usr/lib/ruby/1.8/uri/common.rb:432:in `split': bad URI(is not URI?):
http://ruby-lang.org/ (URI::InvalidURIError)
from /usr/lib/ruby/1.8/uri/common.rb:481:in `parse'
from /usr/lib/ruby/1.8/uri/common.rb:516:in `join'
from /tmp/uri.rb:5
It's helpful if URI's methods accept URI objects as arguments because you will typically construct a new URL from an
old one, and the old one is likely to also be a URI object. Presumably this is just a case of the methods calling 'to_s'
on their arguments.
If the current behaviour is to be retained, then could the error message be clarified? Displaying a valid URL and
simultaneously claiming that it's bad, is, um, bad. :-)
|