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.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-02-04 04: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? :'(
F6a834b9e424a1e5b199db450462b6cd?d=identicon&s=25 Ron Fox (Guest)
on 2009-02-04 12:35
(Received via mailing list)
Tim Mcd 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?
47aff267a58c012d222fd4d74f6beb54?d=identicon&s=25 Dominik Honnef (Guest)
on 2009-02-04 15: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.