Bugs item #10894, was opened at 2007-05-18 14:14
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10894&group_id=426

Category: Standard Library
Group: 1.8.5
Status: Open
Resolution: None
Priority: 3
Submitted By: Ben Coffey (benc)
Assigned to: Nobody (None)
Summary: URI Methods Raise Unclear Exceptions When Passed URI Objects

Initial Comment:
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. :-)


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10894&group_id=426