link_thumbnailer 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,9 @@ module LinkThumbnailer
21
21
  resp = http.request(self.url)
22
22
  case resp
23
23
  when Net::HTTPSuccess then resp.body
24
- when Net::HTTPRedirection then fetch(resp['location'], redirect_count + 1)
24
+ when Net::HTTPRedirection
25
+ location = resp['location'].start_with?('http') ? resp['location'] : "#{self.url.scheme}://#{self.url.host}#{resp['location']}"
26
+ fetch(location, redirect_count + 1)
25
27
  else resp.error!
26
28
  end
27
29
  end
@@ -1,3 +1,3 @@
1
1
  module LinkThumbnailer
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = LinkThumbnailer::VERSION
17
17
 
18
18
  gem.add_dependency(%q{nokogiri}, ['~> 1.5.5'])
19
- gem.add_dependency(%q{hashie}, ['~> 1.2.0'])
19
+ gem.add_dependency(%q{hashie}, ['>= 1.2.0'])
20
20
  gem.add_dependency(%q{net-http-persistent}, ['~> 2.7'])
21
21
  gem.add_dependency(%q{rmagick}, ['~> 2.13.1'])
22
22
  gem.add_dependency(%q{json}, ['~> 1.7.6'])
data/spec/fetcher_spec.rb CHANGED
@@ -40,20 +40,44 @@ describe LinkThumbnailer::Fetcher do
40
40
 
41
41
  context "when http redirection" do
42
42
 
43
- let(:another_url) { 'http://bar.com' }
43
+ context "and relative uri" do
44
44
 
45
- before do
46
- stub_request(:get, url).to_return(status: 300, body: 'foo', headers: { 'Location' => another_url })
47
- stub_request(:get, another_url).to_return(status: 200, body: 'bar', headers: {})
48
- end
45
+ let(:another_url) { '/bar' }
46
+
47
+ before do
48
+ stub_request(:get, url).to_return(status: 300, body: 'foo', headers: { 'Location' => another_url })
49
+ stub_request(:get, url + another_url).to_return(status: 200, body: 'bar', headers: {})
50
+ end
51
+
52
+ it "returns body response" do
53
+ fetcher.fetch(url).should eq('bar')
54
+ end
55
+
56
+ it "sets fetcher url" do
57
+ fetcher.fetch(url)
58
+ fetcher.url.to_s.should eq(url + another_url)
59
+ end
49
60
 
50
- it "returns body response" do
51
- fetcher.fetch(url).should eq('bar')
52
61
  end
53
62
 
54
- it "sets fetcher url" do
55
- fetcher.fetch(url)
56
- fetcher.url.to_s.should eq(another_url)
63
+ context "and absolute uri" do
64
+
65
+ let(:another_url) { 'http://bar.com' }
66
+
67
+ before do
68
+ stub_request(:get, url).to_return(status: 300, body: 'foo', headers: { 'Location' => another_url })
69
+ stub_request(:get, another_url).to_return(status: 200, body: 'bar', headers: {})
70
+ end
71
+
72
+ it "returns body response" do
73
+ fetcher.fetch(url).should eq('bar')
74
+ end
75
+
76
+ it "sets fetcher url" do
77
+ fetcher.fetch(url)
78
+ fetcher.url.to_s.should eq(another_url)
79
+ end
80
+
57
81
  end
58
82
 
59
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_thumbnailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-27 00:00:00.000000000 Z
12
+ date: 2013-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: 1.2.0
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.2.0
46
46
  - !ruby/object:Gem::Dependency