Forum: Ruby URI.parse errors!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tim M. (Guest)
on 2009-02-04 05:20
      resp = Net::HTTP.get(URI.parse("http:#{img['src']}"))

thats the line that is making this error:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:436:in
`split': bad URI(is not URI?):
http://images.slashdot.org/articles/09/02/03/16202...
(URI::InvalidURIError)

How is it invalid? :'(
Ron F. (Guest)
on 2009-02-04 13:35
(Received via mailing list)
Tim M. wrote:
>       resp = Net::HTTP.get(URI.parse("http:#{img['src']}"))
>
> thats the line that is making this error:
>
> 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:436:in
> `split': bad URI(is not URI?):
> http://images.slashdot.org/articles/09/02/03/16202...
> (URI::InvalidURIError)
>
> How is it invalid? :'(
What are the contents of img['src']... do they include the leading
//'s required to make this a good URI?
Dominik H. (Guest)
on 2009-02-04 16:31
(Received via mailing list)
> 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:436:in
> `split': bad URI(is not URI?):
> http://images.slashdot.org/articles/09/02/03/16202...
> (URI::InvalidURIError)
>
> How is it invalid? :'(

Well, according to my irb, it isnt ->
  >>
URI.parse("http://images.slashdot.org/articles/09/02/03/16202...)
  => #<URI::HTTP:0xb7ade668
URL:http://images.slashdot.org/articles/09/02/03/16202...

So it must be something about img['src'], you should #inspect it.
This topic is locked and can not be replied to.