link_oracle 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 384b604e728c753c47f036b2c714b10cf26a8549
4
- data.tar.gz: 0d8c11d04441682e63c0b5a2c644143008fe7530
3
+ metadata.gz: 5037a462b2f18aa3bf1f4ea925c3cefb1697e46a
4
+ data.tar.gz: 824da5dd8ae7e12a8e5c412151c145866641f961
5
5
  SHA512:
6
- metadata.gz: a99406314c99255ec4be08fd66bf60b93491332c5b28a947c1d569e64c90d7d95d60869f01620ccac6231ec9bc22ecd8fa29c9d81a0e702034b09b597ef6730c
7
- data.tar.gz: e3a4a293759f35aa51d9e2ab6b47ec3f60c18f62d32c8967df9435050caf12db5dc0a47db5464035120d933ee8af3b659021e06724861087e2d715e960056c65
6
+ metadata.gz: 17b1f57667b2b5b5470408b6edb9ef46196da92a6a96ba67f98c1e1c70d6d4e51f062890c15e353c4636dadc504b70c50509a83d910b17c188ac87e921547c39
7
+ data.tar.gz: 675f26ded878ecce2d5d179f12c7f81a2f10e251001d8b693fb37945ce2c8b8a0b2f8aca145dbff49139b81dfdd8e5765ffadb77ab96dfc2a6ffc9a472a7b92c
@@ -24,11 +24,17 @@ class LinkOracle
24
24
  end
25
25
 
26
26
  def validate_url
27
- !!URI.parse(url)
27
+ encoded_url = encode_url(url)
28
+ !!URI.parse(encoded_url)
28
29
  rescue URI::InvalidURIError
29
30
  raise InvalidUrl, url
30
31
  end
31
32
 
33
+ def encode_url(url)
34
+ return if url.nil? || url.empty?
35
+ URI.encode(url)
36
+ end
37
+
32
38
  def response
33
39
  @response ||= request
34
40
  end
@@ -1,3 +1,3 @@
1
1
  class LinkOracle
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -88,6 +88,26 @@ describe LinkOracle::Request do
88
88
  }.to raise_error(LinkOracle::InvalidUrl)
89
89
  end
90
90
  end
91
+
92
+ context 'url is blank' do
93
+ let(:url) { '' }
94
+
95
+ it 'should raise InvalidUrl' do
96
+ expect {
97
+ requester.parsed_url
98
+ }.to raise_error(LinkOracle::InvalidUrl)
99
+ end
100
+ end
101
+
102
+ context "the url has weird characters in it" do
103
+ let(:url) { 'http://www.autoblog.com/2014/09/26/porsche-911-nissan-gtr-world-greatest-drag-race-video/?icid=autos|latest-auto-news|content' }
104
+
105
+ it "should encode and not raise an error" do
106
+ expect {
107
+ requester.parsed_url
108
+ }.to_not raise_error(LinkOracle::InvalidUrl)
109
+ end
110
+ end
91
111
  end
92
112
  end
93
113
  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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Cooper
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-10-02 00:00:00.000000000 Z
16
+ date: 2014-10-20 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: nokogiri