fingerprinter 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/fingerprinter.rb +17 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a235ab2c1e2f911a87dd87eaa83d1b81ae974614f57ded0e9c69dd96c946b4d
|
4
|
+
data.tar.gz: f0b6197d8604b4b655a53cd2d7112f2f142e5048135956137518cd1011b1dcc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4720f0b52bf5130c980d759abc42ae829dd64da3feedb3c65c67be159d55500700433ea6d27483a1ff65dd8caa7e3e4b467ca46de7f173c68969df5d2f633815
|
7
|
+
data.tar.gz: f9a778664a1e258ee7894daf4eb9dee52bd40b3e925b5fa6c890df8126c151fc36f979ea97486d1979f9eafdd4a0f285fa42b2029b0a6147abe840ec3b477051
|
data/lib/fingerprinter.rb
CHANGED
@@ -35,7 +35,7 @@ module Fingerprinter
|
|
35
35
|
response = get_response(url)
|
36
36
|
next unless response
|
37
37
|
|
38
|
-
url =
|
38
|
+
url = effective_url(response, url)
|
39
39
|
|
40
40
|
responses = response.redirections
|
41
41
|
responses << response
|
@@ -67,19 +67,31 @@ module Fingerprinter
|
|
67
67
|
if stream_error?(response)
|
68
68
|
return
|
69
69
|
elsif timeout_without_scheme?(url, response)
|
70
|
-
url =
|
70
|
+
url = normalize_url(url)
|
71
71
|
return get_response(url)
|
72
72
|
end
|
73
73
|
return if response&.code == 0
|
74
|
-
return response if same_scope?(url, response)
|
74
|
+
return response if response.redirections.empty? || same_scope?(url, response)
|
75
75
|
|
76
76
|
response.redirections.first
|
77
77
|
end
|
78
78
|
|
79
|
+
def effective_url(response, url)
|
80
|
+
effective_url = Utilities::Urls.up_to_port(response.effective_url)
|
81
|
+
effective_url.nil? ? normalize_url(url) : effective_url
|
82
|
+
end
|
83
|
+
|
84
|
+
def normalize_url(url)
|
85
|
+
url.start_with?('http') ? url : "https://#{url}"
|
86
|
+
end
|
87
|
+
|
79
88
|
def same_scope?(url, response)
|
80
|
-
url =
|
89
|
+
url = normalize_url(url)
|
90
|
+
|
91
|
+
base_host = Utilities::Urls.uri_parse(url)&.host
|
92
|
+
response_host = Utilities::Urls.uri_parse(response&.effective_url)&.host
|
81
93
|
|
82
|
-
|
94
|
+
base_host == response_host || 'www.' + base_host == response_host
|
83
95
|
end
|
84
96
|
|
85
97
|
def stream_error?(response)
|