google_safe_browsing 0.1.0 → 0.2.0
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.
@@ -44,42 +44,62 @@ module GoogleSafeBrowsing
|
|
44
44
|
|
45
45
|
splits = split_host_path(lookup_url)
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
host_string = strip_username_password_and_port_from_host(splits[:host])
|
48
|
+
|
49
|
+
host_strings = [host_string]
|
50
|
+
host = TopLevelDomain.split_from_host(host_string).last(5)
|
49
51
|
( host.length - 1 ).times do
|
50
52
|
host_strings << host.join('.')
|
51
53
|
host.shift
|
52
54
|
end
|
53
55
|
host_strings.uniq!
|
54
56
|
|
55
|
-
|
57
|
+
path_strings = generate_path_strings(splits[:path])
|
58
|
+
|
59
|
+
cart_prod(host_strings, path_strings)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def self.generate_path_strings(raw_path)
|
65
|
+
return [ '/' ] if raw_path == ''
|
66
|
+
|
67
|
+
path_split = raw_path.split('?')
|
56
68
|
path = path_split[0]
|
57
69
|
params = path_split[1]
|
58
70
|
|
59
71
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
path_components = path.split('/').first(3)
|
73
|
+
path_strings = [ '/' ]
|
74
|
+
path_components.length.times do
|
75
|
+
path_strings << '/' + path_components.join('/')
|
76
|
+
path_components.pop
|
77
|
+
end
|
78
|
+
|
79
|
+
path_strings.map! do |p|
|
80
|
+
unless p.index('.')
|
81
|
+
p + '/'
|
82
|
+
else
|
83
|
+
p
|
67
84
|
end
|
68
85
|
end
|
69
|
-
path_strings.map!{ |p|
|
70
|
-
path_strings.map!{ |p| p.gsub!(/\/+/, '/') }
|
86
|
+
path_strings.map!{ |p| p.to_s.gsub!(/\/+/, '/') }
|
71
87
|
path_strings.compact!
|
72
88
|
path_strings.uniq!
|
73
89
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
90
|
+
if params
|
91
|
+
path_strings | path_strings.map do |p|
|
92
|
+
if p[-1..-1] == '/'
|
93
|
+
p
|
94
|
+
else
|
95
|
+
"#{p}?#{params}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
else
|
99
|
+
return path_strings
|
100
|
+
end
|
79
101
|
end
|
80
102
|
|
81
|
-
private
|
82
|
-
|
83
103
|
def self.cart_prod(a_one, a_two)
|
84
104
|
result = []
|
85
105
|
a_one.each do |i|
|
@@ -177,5 +197,28 @@ module GoogleSafeBrowsing
|
|
177
197
|
end
|
178
198
|
cann
|
179
199
|
end
|
200
|
+
|
201
|
+
def self.strip_username_password_and_port_from_host(host_string)
|
202
|
+
host_string = remove_port(host_string)
|
203
|
+
remove_username_and_password(host_string)
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.remove_port(host_string)
|
207
|
+
port_sep = host_string.rindex(':')
|
208
|
+
if port_sep
|
209
|
+
host_string[0..port_sep-1]
|
210
|
+
else
|
211
|
+
host_string
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.remove_username_and_password(host_string)
|
216
|
+
un_sep = host_string.index('@')
|
217
|
+
if un_sep
|
218
|
+
host_string[un_sep+1..-1]
|
219
|
+
else
|
220
|
+
host_string
|
221
|
+
end
|
222
|
+
end
|
180
223
|
end
|
181
224
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_safe_browsing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Marshall
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02
|
18
|
+
date: 2012-03-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
prerelease: false
|