micky 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d37d983af555a2d4a857277e50fa39a459ff9d
4
- data.tar.gz: da23a33bce7a1ae50fba2955b8fee23e0e6b1b0f
3
+ metadata.gz: 69d2ab4b7b2dbf26fe03841cbfed112bd4d75eb0
4
+ data.tar.gz: c5849d98557ce9e9612ef490f197d326c5783e5d
5
5
  SHA512:
6
- metadata.gz: 91679a202a326830c39ce3f5727f2b3673e657c525cf8c32a21ea550eb6622704928ea57a82407b3e04853a6226b6277dbba1b8f433cb9928f6c8985b3f5f374
7
- data.tar.gz: eb009b79b092ebc34382ee4dae894368da24cb96df1aad6418110c9b7017d8180b1f1f33aacb437f1ea5731abcce84b35d3fdc634d9a6f9d8746f3ea0795a4e2
6
+ metadata.gz: 5080fda9b4c7c811e7aa78ea9360a25a6768d5c3e38c21751c5e6a78536f78cc413c42c4843aa8c97a3bbc1d412eed4337a74ad1362412c051b71cd74d692799
7
+ data.tar.gz: ac330e86b9bc28ae009e262596e2546d6830b9b221352e8c92181cd09f7889c369136ae98cab0b9348bafea487d9a43159dccc1d74f1a33402c0d724070aea2e
data/lib/micky/request.rb CHANGED
@@ -34,7 +34,25 @@ module Micky
34
34
  when Net::HTTPSuccess
35
35
  Response.new(response)
36
36
  when Net::HTTPRedirection
37
+ previous_uri = uri
37
38
  uri = response['Location']
39
+
40
+ if uri !~ Micky::HTTP_URI_REGEX
41
+ if uri.start_with? '//'
42
+ # Protocol-relative
43
+ uri = Micky::URI(uri).to_s
44
+ elsif uri.start_with? '/'
45
+ # Host-relative
46
+ previous_uri = Micky::URI(previous_uri)
47
+ uri = File.join("#{previous_uri.scheme}://#{previous_uri.host}", uri)
48
+ else
49
+ # Path-relative
50
+ previous_uri = Micky::URI(previous_uri)
51
+ previous_directory = previous_uri.path.sub(/[^\/]+\z/, '')
52
+ uri = File.join("#{previous_uri.scheme}://#{previous_uri.host}#{previous_directory}", uri)
53
+ end
54
+ end
55
+
38
56
  log "Redirect to #{uri}"
39
57
  request_with_redirect_handling(uri, redirect_count + 1)
40
58
  else
data/lib/micky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Micky
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafaël Blais Masson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.2.2
82
+ rubygems_version: 2.4.5
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Lightweight and worry-free HTTP client