link_oracle 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31d4f4ed9576a0db912307886f56ee7c908c2508
4
- data.tar.gz: a20c3f61a0b7c02e1d7cd0c3b1e310264cbdb7b9
3
+ metadata.gz: ffdf6cdb72710f8ec487c1118d15a031c79958ab
4
+ data.tar.gz: ab1a3ea91f64b826fac48953777124f4c33c4e02
5
5
  SHA512:
6
- metadata.gz: 2796582749c379e8e86f1b48025f9be30de7da7d615b146e1ec1733ada8ecf1b77d4cc5b463e927dbb6238e8a6171217c5e65c8ad79830d6ecc4556d657119e6
7
- data.tar.gz: fbd4ce096e982d9b9bdc9e4b84f5992a7686554836b78ee8140f00a09dfbd71450967291c112752385174d4aa889a39b7ce43ae29ab57e9cda1a79c29c310e6d
6
+ metadata.gz: ff1d2bf9b3b49cc242f60810186e4bfe08108de08481d2e4d6d9cf37a7f6baa93b0b5a50eea6070a5232b27e428a555c82f3d35d9fa5c7ba8074a0a1497f784d
7
+ data.tar.gz: 3e33d251e92a0c7b5bf1a45e9bbc33abc61d1c12c87230b34dfb7cae45d63077b6e2177246f9290135a1994868cbe722468b62597bfafb0d7e7f6c25fc30d525
@@ -8,7 +8,12 @@ module Utils
8
8
  end
9
9
 
10
10
  def perform
11
- invalid_url? ? "#{scheme}://#{host}#{image_url}" : image_url
11
+ return unless image_url
12
+ invalid_url? ? "#{scheme}://#{host}#{encoded_image_url}" : encoded_image_url
13
+ end
14
+
15
+ def encoded_image_url
16
+ URI.encode(image_url)
12
17
  end
13
18
 
14
19
  def host
@@ -23,8 +28,12 @@ module Utils
23
28
  @parsed_url ||= URI.parse(url)
24
29
  end
25
30
 
31
+ def parsed_image_url
32
+ @parsed_image_url ||= URI.parse(encoded_image_url)
33
+ end
34
+
26
35
  def invalid_url?
27
- image_url[0] == '/'
36
+ !parsed_image_url.host
28
37
  end
29
38
  end
30
- end
39
+ end
@@ -1,4 +1,4 @@
1
1
  class LinkOracle
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
4
4
 
@@ -17,4 +17,17 @@ describe Utils::ImageUrlFormatter do
17
17
  formatted_url.should == 'https://berkin.com/some/stupid/path'
18
18
  end
19
19
  end
20
+
21
+ context 'image_url is nil' do
22
+ let(:image_url) { nil }
23
+ it 'fails silently' do
24
+ expect {
25
+ formatted_url
26
+ }.not_to raise_error
27
+ end
28
+
29
+ it 'returns nil' do
30
+ formatted_url.should == nil
31
+ end
32
+ end
20
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_oracle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Cooper