url_canonicalize 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/url_canonicalize/request.rb +6 -8
- data/lib/url_canonicalize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9843f990e987c4724142b84af26556ebc39506c5
|
4
|
+
data.tar.gz: d6d7772634ae4c1e1e047426fe4f73793ccfea55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70070a42151902f6ac717975a4b1eb9e127e139ee48108e269225742a21e76d95dc3150966d4fb36e8544f26454c8e790beb98e90c19758bcb1f41cc0fa16538
|
7
|
+
data.tar.gz: 2877f4747861cd3b5d0a68dcd9ffeec42b2d1f868214dd903cb1fd7ceabefe82c4ca39032d13552a219d32d4891e575ce09392fe3cc4fb371f05289904e53597
|
@@ -15,6 +15,7 @@ module URLCanonicalize
|
|
15
15
|
|
16
16
|
@url = nil
|
17
17
|
@host = nil
|
18
|
+
@request = nil
|
18
19
|
@response = nil
|
19
20
|
@location = nil
|
20
21
|
@html = nil
|
@@ -60,20 +61,17 @@ module URLCanonicalize
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def handle_success
|
63
|
-
@canonical_url = $LAST_MATCH_INFO['url'] if /<(?<url>.+)>\s*;\s*rel="canonical"/i
|
64
|
+
@canonical_url = $LAST_MATCH_INFO['url'] if (response['link'] || '') =~ /<(?<url>.+)>\s*;\s*rel="canonical"/i
|
64
65
|
|
65
|
-
if http_method == :
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
enhanced_response
|
70
|
-
end
|
66
|
+
return enhanced_response if canonical_url || http_method == :get
|
67
|
+
|
68
|
+
self.http_method = :get
|
69
|
+
fetch
|
71
70
|
end
|
72
71
|
|
73
72
|
def handle_redirection
|
74
73
|
case response
|
75
74
|
when Net::HTTPFound, Net::HTTPMovedTemporarily, Net::HTTPTemporaryRedirect # Temporary redirection
|
76
|
-
self.http_method = :get
|
77
75
|
handle_success
|
78
76
|
else # Permanent redirection
|
79
77
|
if location
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_canonicalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Sayers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|