Raise error correctly on bad url scheme, fixes #156

This commit is contained in:
Stephen Sykes 2025-01-02 19:44:19 +00:00
parent e7d8111784
commit a891d8f43a
2 changed files with 7 additions and 0 deletions

View File

@ -291,6 +291,8 @@ class FastImage
end
def fetch_using_http_from_parsed_uri
raise ImageFetchFailure unless @parsed_uri.is_a?(URI::HTTP)
http_header = {'Accept-Encoding' => 'identity'}.merge(@options[:http_header])
setup_http

View File

@ -535,4 +535,9 @@ class FastImageTest < Test::Unit::TestCase
fi.size
assert_equal 322, fi.content_length
end
def test_unknown_protocol
FakeWeb.register_uri(:get, "http://example.com/test", body: "", location: "hhttp://example.com", :status => 301)
assert_nil FastImage.size("http://example.com/test")
end
end