Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
URI.parse issue with ruby-trunk.
irb(main):014:0* url = "https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o"
=> "https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o"
irb(main):015:0> URI.encode url
=> "https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o"
irb(main):016:0> URI.parse url
URI::InvalidURIError: bad URI(is not URI?): https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o
from /Users/artega/.rubies/ruby-trunk/lib/ruby/2.2.0/uri/rfc3986_parser.rb:47:in `split'
from /Users/artega/.rubies/ruby-trunk/lib/ruby/2.2.0/uri/rfc3986_parser.rb:53:in `parse'
from /Users/artega/.rubies/ruby-trunk/lib/ruby/2.2.0/uri/common.rb:223:in `parse'
from (irb):16
from /Users/artega/.rubies/ruby-trunk/bin/irb:11:in `<main>'
@lengarvey

This comment has been minimized.

Copy link
Owner Author

@lengarvey lengarvey commented Jun 28, 2014

The problem is caused by URI.parse using the new URI::RFC3896_Parser but URI.encode uses the old URI::RFC2396_Parser.

@lengarvey

This comment has been minimized.

Copy link
Owner Author

@lengarvey lengarvey commented Jun 28, 2014

URI::RFC3896_Parser doesn't implement #escape so there isn't a straightforward solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.