fastimage 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastimage.rb +7 -1
  3. data/test/test.rb +6 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3543a9d79c335da93081dd89b99159c51cfa05b9
4
- data.tar.gz: 896de6c0e1ba2ec71b952b17e276b395f2d28d11
3
+ metadata.gz: 11238027e508393256ccfe75fa2efc2bc14a36a8
4
+ data.tar.gz: 9b3531e4c50fec753454798d0a041e7424522502
5
5
  SHA512:
6
- metadata.gz: 58d0d3c73b5d3d01cb5b6adb9cd86526600c12e2371742fcfd5391587fe3fe7f9f63b389e61ffafc770e11502d27a505122afb635818656d901540d7e32aeb35
7
- data.tar.gz: d6ebcdb6272c9c9d56cd6333183ad67d08d994a7d24033ef7e5c42d263a9779c261fdde06db2fa9eb4419fe5b692e3dd8215eb501d22f8191e31c9967b7f2216
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
- @parsed_uri = URI.parse(res['Location'])
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.1
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-17 00:00:00.000000000 Z
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.