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 +4 -4
- data/lib/link_oracle/request.rb +7 -1
- data/lib/link_oracle/version.rb +1 -1
- data/spec/link_oracle/request_spec.rb +20 -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: 5037a462b2f18aa3bf1f4ea925c3cefb1697e46a
|
4
|
+
data.tar.gz: 824da5dd8ae7e12a8e5c412151c145866641f961
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b1f57667b2b5b5470408b6edb9ef46196da92a6a96ba67f98c1e1c70d6d4e51f062890c15e353c4636dadc504b70c50509a83d910b17c188ac87e921547c39
|
7
|
+
data.tar.gz: 675f26ded878ecce2d5d179f12c7f81a2f10e251001d8b693fb37945ce2c8b8a0b2f8aca145dbff49139b81dfdd8e5765ffadb77ab96dfc2a6ffc9a472a7b92c
|
data/lib/link_oracle/request.rb
CHANGED
@@ -24,11 +24,17 @@ class LinkOracle
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def validate_url
|
27
|
-
|
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
|
data/lib/link_oracle/version.rb
CHANGED
@@ -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.
|
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-
|
16
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: nokogiri
|