qeweney 0.7.3 → 0.7.4

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
  SHA256:
3
- metadata.gz: 8410ab97bb9ce59f14cd87659fa5eeb77595f2a4a1fad873392e403d0b27a80a
4
- data.tar.gz: 5b8404bf25b0b23cb72f0e3e919245d7f41361b692601f0e1bf5b208bc0215ed
3
+ metadata.gz: a7beaa70b4d37af5b9bb46aa06bcd78e6d9353eada5715e28d22bc8b5fac61a4
4
+ data.tar.gz: 030c6f1fb05fde6ae12c2bb61844c98b9e821b4f7e21f1e7d51fa934814bc3b1
5
5
  SHA512:
6
- metadata.gz: 5ec5cb26a660c15cd465c04597c8135857f18b5cf8f706582243e3406f9163038c515d4d7a13678777ad71ab4c6fe26b11b35df8d27673316cf423f844c0529d
7
- data.tar.gz: 85d6961f2eb42cf6d7299318e24dbf0ac697a89051667be99fc485b1359c0a0365eabeb69bbe2744d70bbefe9bcbce0226a1cf37196480defc7a6845572963e8
6
+ metadata.gz: 82b3104f93f3ac826f2c4319fb4c9c324efbb490983af4b8035f402fcb04c13f8f8f28dd2443764dcff26e9d7e33f0eb071c3ec0005acefd4fe27cbd13d314e4
7
+ data.tar.gz: 9629ed95b4b7397fc8c15ef1b10b8948d31fc047e913c5aab9b7450eaa4ff31cbf7dde4b027870757eb02c0d72e00d8f766c57871aca9fc6948a75ed90adb769
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.7.4 2021-03-07
2
+
3
+ - Add `Request#cookies`
4
+ - Add `Request#full_uri`
5
+
1
6
  ## 0.7.3 2021-03-05
2
7
 
3
8
  - Fix `parse_urlencoded_form_data`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.7.3)
4
+ qeweney (0.7.4)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -37,6 +37,10 @@ module Qeweney
37
37
  @uri ||= URI.parse(@headers[':path'] || '')
38
38
  end
39
39
 
40
+ def full_uri
41
+ @full_uri = "#{scheme}://#{host}#{uri}"
42
+ end
43
+
40
44
  def path
41
45
  @path ||= uri.path
42
46
  end
@@ -74,6 +78,22 @@ module Qeweney
74
78
 
75
79
  encoding.split(',').map { |i| i.strip }
76
80
  end
81
+
82
+ def cookies
83
+ @cookies ||= parse_cookies(headers['cookie'])
84
+ end
85
+
86
+ COOKIE_RE = /^([^=]+)=(.*)$/.freeze
87
+ SEMICOLON = ';'
88
+
89
+ def parse_cookies(cookies)
90
+ cookies.split(SEMICOLON).each_with_object({}) do |c, h|
91
+ raise BadRequestError, 'Invalid cookie format' unless c.strip =~ COOKIE_RE
92
+
93
+ key, value = Regexp.last_match[1..2]
94
+ h[key] = EscapeUtils.unescape_uri(value)
95
+ end
96
+ end
77
97
  end
78
98
 
79
99
  module RequestInfoClassMethods
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qeweney
4
- VERSION = '0.7.3'
4
+ VERSION = '0.7.4'
5
5
  end
@@ -20,4 +20,26 @@ class RequestInfoTest < MiniTest::Test
20
20
  r = Qeweney.mock('host' => 'my.example.com')
21
21
  assert_equal 'my.example.com', r.host
22
22
  end
23
+
24
+ def test_full_uri
25
+ r = Qeweney.mock(
26
+ ':scheme' => 'https',
27
+ 'host' => 'foo.bar',
28
+ ':path' => '/hey?a=b&c=d'
29
+ )
30
+
31
+ assert_equal 'https://foo.bar/hey?a=b&c=d', r.full_uri
32
+ end
33
+
34
+ def test_cookies
35
+ r = Qeweney.mock(
36
+ 'cookie' => 'uaid=a%2Fb; lastLocus=settings; signin_ref=/'
37
+ )
38
+
39
+ assert_equal({
40
+ 'uaid' => 'a/b',
41
+ 'lastLocus' => 'settings',
42
+ 'signin_ref' => '/'
43
+ }, r.cookies)
44
+ end
23
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qeweney
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-05 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.1.4
139
+ rubygems_version: 3.0.8
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Qeweney - cross library HTTP request / response API