qeweney 0.8 → 0.9.0

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: ccff703b19924cf5dc8797b02a5338f12d990eacfa4fbcebf35123dae7f8840e
4
- data.tar.gz: 385e5518ff1715d6e57b95f01ee6edfbcc45b49dfab3105d51014cd4a68a92cd
3
+ metadata.gz: 1fbf7ec4eb0c73fef2003190fd086c46fff0edc74ab4544c5a36b7d6fcce4041
4
+ data.tar.gz: 328254edf151b4ce1acc201438b315eb6569c96868b84b9160a2ed0ff0636870
5
5
  SHA512:
6
- metadata.gz: 234aac50cd2f39f754d31fac0e401d06a8117f771de69d1840fcfb43f31b748df521a658eae3ff3989eb4683d76d2999fb2b510c80cef578218cf4d4b90f1ed1
7
- data.tar.gz: b2c2b1f2a3109f5438862877aa0283c54a0818154f310fde257fdec01e92356972e88cbf3508050843d4434a6735f45ec79e9a559f9a8e3e1819c714957f3161
6
+ metadata.gz: 31ba2523f8ef5dd0155eaba082967b1a2ee97bea5f40b319c3b3110e9cb549032909a95c9a5147161ed2613a9c3f8688d81496286684876c614f0b185629232b
7
+ data.tar.gz: 2d2b4a3b7a30b6a6ec5fa83c95e2b19a37bad50ab195af011ca52f504f597069d4d3ef0a60e6553a99132baac506fe6e0be570532392557be207923125f47577
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 0.9.0 2021-05-14
2
+
3
+ - Fix query parsing for fields with empty value
4
+
5
+ ## 0.8.4 2021-03-23
6
+
7
+ - Rename and fix `#parse_query` to deal with no-value query parts
8
+
9
+ ## 0.8.3 2021-03-22
10
+
11
+ - Streamline routing behaviour in sub routes (an explicit default sub route is
12
+ now required if no sub route matches)
13
+
14
+ ## 0.8.2 2021-03-17
15
+
16
+ - Fix form parsing when charset is specified
17
+
18
+ ## 0.8.1 2021-03-10
19
+
20
+ - Add `Request#transfer_counts`, `Request#total_transfer`
21
+ - Fix `Request#rx_incr`
22
+
1
23
  ## 0.8 2021-03-10
2
24
 
3
25
  - Pass request as first argument to all adapter methods
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.8)
4
+ qeweney (0.9.0)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -106,11 +106,19 @@ module Qeweney
106
106
  end
107
107
 
108
108
  def rx_incr(count)
109
- headers[':rx'] ? headers[';rx'] += count : headers[':rx'] = count
109
+ headers[':rx'] ? headers[':rx'] += count : headers[':rx'] = count
110
110
  end
111
111
 
112
112
  def tx_incr(count)
113
113
  headers[':tx'] ? headers[':tx'] += count : headers[':tx'] = count
114
114
  end
115
+
116
+ def transfer_counts
117
+ [headers[':rx'], headers[':tx']]
118
+ end
119
+
120
+ def total_transfer
121
+ (headers[':rx'] || 0) + (headers[':tx'] || 0)
122
+ end
115
123
  end
116
124
  end
@@ -52,14 +52,16 @@ module Qeweney
52
52
  def query
53
53
  return @query if @query
54
54
 
55
- @query = (q = uri.query) ? split_query_string(q) : {}
55
+ @query = (q = uri.query) ? parse_query(q) : {}
56
56
  end
57
57
 
58
- def split_query_string(query)
58
+ QUERY_KV_REGEXP = /([^=]+)(?:=(.*))?/
59
+
60
+ def parse_query(query)
59
61
  query.split('&').each_with_object({}) do |kv, h|
60
- k, v = kv.split('=')
61
- p split_query_string: { k: k, v: v }
62
- h[k.to_sym] = URI.decode_www_form_component(v)
62
+ k, v = kv.match(QUERY_KV_REGEXP)[1..2]
63
+ # k, v = kv.split('=')
64
+ h[k.to_sym] = v ? URI.decode_www_form_component(v) : true
63
65
  end
64
66
  end
65
67
 
@@ -102,10 +104,10 @@ module Qeweney
102
104
  module RequestInfoClassMethods
103
105
  def parse_form_data(body, headers)
104
106
  case (content_type = headers['content-type'])
105
- when /multipart\/form\-data; boundary=([^\s]+)/
107
+ when /^multipart\/form\-data; boundary=([^\s]+)/
106
108
  boundary = "--#{Regexp.last_match(1)}"
107
109
  parse_multipart_form_data(body, boundary)
108
- when 'application/x-www-form-urlencoded'
110
+ when /^application\/x-www-form-urlencoded/
109
111
  parse_urlencoded_form_data(body)
110
112
  else
111
113
  raise "Unsupported form data content type: #{content_type}"
@@ -16,7 +16,7 @@ module Qeweney
16
16
 
17
17
  def route_found(&block)
18
18
  catch(:stop, &block)
19
- throw :stop, headers_sent? ? :found : nil
19
+ throw :stop, :found
20
20
  end
21
21
 
22
22
  @@regexp_cache = {}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qeweney
4
- VERSION = '0.8'
4
+ VERSION = '0.9.0'
5
5
  end
@@ -13,6 +13,19 @@ class RequestInfoTest < MiniTest::Test
13
13
  assert_equal({ a: '1', b: '2', c: '3/4' }, r.query)
14
14
  end
15
15
 
16
+ def test_query
17
+ r = Qeweney.mock(':path' => '/GponForm/diag_Form?images/')
18
+ assert_equal '/GponForm/diag_Form', r.path
19
+ assert_equal({:'images/' => true}, r.query)
20
+
21
+ r = Qeweney.mock(':path' => '/?a=1&b=2')
22
+ assert_equal '/', r.path
23
+ assert_equal({a: '1', b: '2'}, r.query)
24
+
25
+ r = Qeweney.mock(':path' => '/?l=a&t=&x=42')
26
+ assert_equal({l: 'a', t: '', x: '42'}, r.query)
27
+ end
28
+
16
29
  def test_host
17
30
  r = Qeweney.mock(':path' => '/')
18
31
  assert_nil r.host
data/test/test_routing.rb CHANGED
@@ -12,6 +12,7 @@ class RoutingTest < MiniTest::Test
12
12
  r.on_post do
13
13
  r.redirect '/'
14
14
  end
15
+ r.default { r.respond nil, ':status' => 404 }
15
16
  end
16
17
  end
17
18
  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.8'
4
+ version: 0.9.0
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-10 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils