sitemap_checker 0.1.3 → 0.1.4
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.
- data/lib/sitemap_checker.rb +2 -1
- data/lib/sitemap_checker/open_uri.rb +40 -0
- data/lib/sitemap_checker/path.rb +3 -1
- data/lib/sitemap_checker/version.rb +1 -1
- metadata +2 -1
data/lib/sitemap_checker.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
#
|
3
|
+
# From: https://gist.github.com/1271420
|
4
|
+
#
|
5
|
+
# Allow open-uri to follow unsafe redirects (i.e. https to http).
|
6
|
+
# Relevant issue:
|
7
|
+
# http://redmine.ruby-lang.org/issues/3719
|
8
|
+
# Source here:
|
9
|
+
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
|
10
|
+
module OpenURI
|
11
|
+
class <<self
|
12
|
+
alias_method :open_uri_original, :open_uri
|
13
|
+
alias_method :redirectable_cautious?, :redirectable?
|
14
|
+
|
15
|
+
def redirectable_baller? uri1, uri2
|
16
|
+
valid = /\A(?:https?|ftp)\z/i
|
17
|
+
valid =~ uri1.scheme.downcase && valid =~ uri2.scheme
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# The original open_uri takes *args but then doesn't do anything with them.
|
22
|
+
# Assume we can only handle a hash.
|
23
|
+
def self.open_uri name, options = {}, &block
|
24
|
+
value = options.delete :allow_unsafe_redirects
|
25
|
+
|
26
|
+
if value
|
27
|
+
class <<self
|
28
|
+
remove_method :redirectable?
|
29
|
+
alias_method :redirectable?, :redirectable_baller?
|
30
|
+
end
|
31
|
+
else
|
32
|
+
class <<self
|
33
|
+
remove_method :redirectable?
|
34
|
+
alias_method :redirectable?, :redirectable_cautious?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
self.open_uri_original name, options, &block
|
39
|
+
end
|
40
|
+
end
|
data/lib/sitemap_checker/path.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
42
|
- lib/sitemap_checker.rb
|
43
|
+
- lib/sitemap_checker/open_uri.rb
|
43
44
|
- lib/sitemap_checker/path.rb
|
44
45
|
- lib/sitemap_checker/sitemap.rb
|
45
46
|
- lib/sitemap_checker/version.rb
|