bad_link_finder 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/bad_link_finder/link.rb +7 -0
- data/lib/bad_link_finder/version.rb +1 -1
- data/test/unit/link_test.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTkzYzA3MDcwZjBkODJiN2VmZWM0OGRlODllMzFiZGJiMGQxNjc1Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDNmNDg2NjYwODNmN2IwNGQyNTllZGQ3Yjc2ZTY0MjU4Y2JkMTBkMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWI0NGU1MTBiMzIyZDE2MTU0YmUxNTM5MWQyZTE3YTUwZjMyZThiYTcxNzA3
|
10
|
+
MjEzYWYxOWE0NTBmZjg2ZGJiYmQxZmYwMWEzNzA1NWJjNjEwM2RhMGJmZmNi
|
11
|
+
MzQ2NGU3NGMxNWI0MmFlYjdlNjYxODY5N2ExZjQ3OGQ3YThiZDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWEzMmE1NGRlNmUwOGVkNmY3ZDNmMTNkZjc3MzVkMTZlOTY1ZGRjY2M2YWM5
|
14
|
+
NDI0ZTYxNTg0MzVlYTcwZjUyNDMwNGE5OTcxYmFkMjJiMGUxOTUzZGIxODQ1
|
15
|
+
NmEzNjM5OTBhZWE1ZTk4OTgzZTBjYTU5ZmViM2Y5N2M3Y2ZlZDI=
|
data/lib/bad_link_finder/link.rb
CHANGED
@@ -9,6 +9,7 @@ module BadLinkFinder
|
|
9
9
|
@link = link
|
10
10
|
@url = get_url_from_link(link)
|
11
11
|
|
12
|
+
verify_url(@url)
|
12
13
|
validate_with_request
|
13
14
|
|
14
15
|
rescue URI::InvalidURIError => exception
|
@@ -60,6 +61,12 @@ module BadLinkFinder
|
|
60
61
|
URI.join(@page_url, link).to_s
|
61
62
|
end
|
62
63
|
|
64
|
+
def verify_url(url)
|
65
|
+
if url.start_with?('http')
|
66
|
+
raise URI::InvalidURIError.new("The URL #{url} should start with http:// or https://") unless url =~ %r{^https?://}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
63
70
|
def record_error(message, exception = nil)
|
64
71
|
@error_message = message
|
65
72
|
@exception = exception
|
data/test/unit/link_test.rb
CHANGED
@@ -27,10 +27,17 @@ describe BadLinkFinder::Link do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "reports malformed links without checking the internet" do
|
30
|
-
|
30
|
+
hrefs = [
|
31
|
+
'htt[]://{an-example-path}',
|
32
|
+
'http:www.example.com'
|
33
|
+
]
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
hrefs.each do |href|
|
36
|
+
link = build_link(href)
|
37
|
+
|
38
|
+
refute link.valid?
|
39
|
+
assert_equal "This link is in a bad format", link.error_message
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
it "reports links returning failure status codes" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bad_link_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Crosby-McCullough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|