fastimage 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastimage.rb +7 -1
- data/test/test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11238027e508393256ccfe75fa2efc2bc14a36a8
|
4
|
+
data.tar.gz: 9b3531e4c50fec753454798d0a041e7424522502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3a12f33f14b539c8c5fd6353f23db8b3859146e557e617e08362fb97c55d84464ae22a97f3a03200d85ec8b7d0787c390c977646db68137eac038026ac332f
|
7
|
+
data.tar.gz: 05625286544b107917f208ee8c33814c6d1d07bc6fa445113c7a9f5d323a8233425489cc324c1611c9718cf4d57a12a450d7cb35eb9e8bd71252015eae4589ea
|
data/lib/fastimage.rb
CHANGED
@@ -209,7 +209,13 @@ class FastImage
|
|
209
209
|
if res.is_a?(Net::HTTPRedirection) && @redirect_count < 4
|
210
210
|
@redirect_count += 1
|
211
211
|
begin
|
212
|
-
|
212
|
+
newly_parsed_uri = URI.parse(res['Location'])
|
213
|
+
# The new location may be relative - check for that
|
214
|
+
if newly_parsed_uri.scheme != "http" && newly_parsed_uri.scheme != "https"
|
215
|
+
@parsed_uri.path = res['Location']
|
216
|
+
else
|
217
|
+
@parsed_uri = newly_parsed_uri
|
218
|
+
end
|
213
219
|
rescue URI::InvalidURIError
|
214
220
|
else
|
215
221
|
fetch_using_http_from_parsed_uri
|
data/test/test.rb
CHANGED
@@ -186,6 +186,12 @@ class FastImageTest < Test::Unit::TestCase
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
def test_should_handle_permanent_redirect_with_relative_url
|
190
|
+
url = "http://example.nowhere/foo.jpeg"
|
191
|
+
register_redirect(url, "/" + GoodFixtures.keys.first)
|
192
|
+
assert_equal GoodFixtures[GoodFixtures.keys.first][1], FastImage.size(url, :raise_on_failure=>true)
|
193
|
+
end
|
194
|
+
|
189
195
|
def register_redirect(from, to)
|
190
196
|
resp = Net::HTTPMovedPermanently.new(1.0, 302, "Moved")
|
191
197
|
resp['Location'] = to
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Sykes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: FastImage finds the size or type of an image given its uri by fetching
|
14
14
|
as little as needed.
|