Skip to content

Commit

Permalink
Raise error correctly on bad url scheme, fixes #156
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsykes committed Jan 2, 2025
1 parent e7d8111 commit a891d8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fastimage/fastimage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ def escaped_location(location)
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
Expand Down
5 changes: 5 additions & 0 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,9 @@ def test_content_length_after_size
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

0 comments on commit a891d8f

Please sign in to comment.