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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64cf70fdd7f0e97ae3ebdc4b2574c9fd7c4d30bd
4
- data.tar.gz: f67c306acbfef65af2dbf884fe9ea0fc8219e167
3
+ metadata.gz: 9843f990e987c4724142b84af26556ebc39506c5
4
+ data.tar.gz: d6d7772634ae4c1e1e047426fe4f73793ccfea55
5
5
  SHA512:
6
- metadata.gz: 0d9afc04d8050eb1e3cdb43a9fa34953cc2feab0546ad09dc6ec235e058090edbcd46e741a46fca87e0621137f7671bcaf89f19eca8d0b0e2f34e525cde5e25e
7
- data.tar.gz: 0ee4ab39a5d43fa2a69a8e5ce35b425dcc7a6861ed46899ac0026b5e14cc928c7b4410d3f6212168b377d9b100a662c4c5a63eabb5c1ed7528bf530fdf5363e2
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 =~ (response['link'] || '')
64
+ @canonical_url = $LAST_MATCH_INFO['url'] if (response['link'] || '') =~ /<(?<url>.+)>\s*;\s*rel="canonical"/i
64
65
 
65
- if http_method == :head
66
- self.http_method = :get
67
- fetch
68
- else
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module URLCanonicalize
3
- VERSION = '0.1.14'
3
+ VERSION = '0.1.15'
4
4
  end
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.14
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-13 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable