fingerprinter 0.1.4 → 0.1.6
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.
- checksums.yaml +4 -4
- data/lib/fingerprinter.rb +33 -6
- metadata +2 -2
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
|
@@ -59,20 +59,47 @@ module Fingerprinter
|
|
59
59
|
response = nil
|
60
60
|
3.times do
|
61
61
|
response = Fingerprinter.http_client.get(url, { follow_location: true })[url]
|
62
|
-
break if response&.code != 0
|
62
|
+
break if response&.code != 0 || timeout_without_scheme?(url, response)
|
63
63
|
|
64
64
|
sleep(1)
|
65
65
|
end
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
if stream_error?(response)
|
68
|
+
return
|
69
|
+
elsif timeout_without_scheme?(url, response)
|
70
|
+
url = normalize_url(url)
|
71
|
+
return get_response(url)
|
72
|
+
end
|
73
|
+
return if response&.code == 0
|
74
|
+
return response if response.redirections.empty? || same_scope?(url, response)
|
68
75
|
|
69
76
|
response.redirections.first
|
70
77
|
end
|
71
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
|
+
|
72
88
|
def same_scope?(url, response)
|
73
|
-
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
|
93
|
+
|
94
|
+
base_host == response_host || 'www.' + base_host == response_host
|
95
|
+
end
|
96
|
+
|
97
|
+
def stream_error?(response)
|
98
|
+
response&.code&.zero? && response.return_message.include?('Stream error')
|
99
|
+
end
|
74
100
|
|
75
|
-
|
101
|
+
def timeout_without_scheme?(url, response)
|
102
|
+
response&.code == 0 && !url.start_with?('http') && response.return_message.include?('Timeout was reached')
|
76
103
|
end
|
77
104
|
end
|
78
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingerprinter
|
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
|
- Joshua MARTINELLE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|