qeweney 0.8.2 → 0.10

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
  SHA256:
3
- metadata.gz: 5df52e7e0b995f2e515f13dd405b8113f82c9ff56029fc7124e6c72bb1782354
4
- data.tar.gz: 64f53dd7900143576734f6d05942dd8bea23dcec3f3f913f48f384ea6c1928a8
3
+ metadata.gz: '048091b6174ddf88ab76f9676514db59d42a77d363db9be53d90e16235322ac7'
4
+ data.tar.gz: 8b346882f337e3b48bd8dd17dc2345458df6fc01c74a9a96d9d94bae31f2d841
5
5
  SHA512:
6
- metadata.gz: 5d932768bd895b3dcbcc72ebad4ef37cb5ed5a02db856af446bc24face24d515715515a12a4617d0f070ef579aa6cbdf95dd17e9dc3d83fceb322c9b595c47df
7
- data.tar.gz: cc0c52ffe47b2ae0244660e02c66929f48a97093f30de028b0364c45285d6b667011e74aa14d8be847cb5f16f221630f16ee8751af940273f986a8668033d2be
6
+ metadata.gz: a1c9db7e7e6c494124f6306b3de4e43bd5d58d2148cef0bea8ef653598c2ba2e5fe3220b0009aa35d43085267572c0a0914db0cb568c2de93be89c66a97470af
7
+ data.tar.gz: '09693533b8686a6aeddb8d409434c3e3dfd212e04ff1364adcc79feb1c74c65d2526f087107374df366e96a1dc3edaf71b5876e69f10ac5886e5d41d0aec6e93'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 0.10.0 2021-06-24
2
+
3
+ - Include file stat in `#serve_io` options as hint for adapter
4
+ - Fix `MimeTypes#[]` for empty extension
5
+
6
+ ## 0.9.1 2021-06-14
7
+
8
+ - Fix reading host from `:authority` header
9
+
10
+ ## 0.9.0 2021-05-14
11
+
12
+ - Fix query parsing for fields with empty value
13
+
14
+ ## 0.8.4 2021-03-23
15
+
16
+ - Rename and fix `#parse_query` to deal with no-value query parts
17
+
18
+ ## 0.8.3 2021-03-22
19
+
20
+ - Streamline routing behaviour in sub routes (an explicit default sub route is
21
+ now required if no sub route matches)
22
+
1
23
  ## 0.8.2 2021-03-17
2
24
 
3
25
  - Fix form parsing when charset is specified
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.8.2)
4
+ qeweney (0.10)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -19,12 +19,16 @@ module Qeweney
19
19
  'json' => 'application/json',
20
20
  }.freeze
21
21
 
22
+ EXT_REGEXP = /\.?([^\.]+)$/.freeze
23
+
22
24
  def self.[](ref)
23
25
  case ref
24
26
  when Symbol
25
27
  TYPES[ref.to_s]
26
- when /\.?([^\.]+)$/
28
+ when EXT_REGEXP
27
29
  TYPES[Regexp.last_match(1)]
30
+ when ''
31
+ nil
28
32
  else
29
33
  raise "Invalid argument #{ref.inspect}"
30
34
  end
@@ -6,8 +6,9 @@ require 'escape_utils'
6
6
  module Qeweney
7
7
  module RequestInfoMethods
8
8
  def host
9
- @headers['host']
9
+ @headers['host'] || @headers[':authority']
10
10
  end
11
+ alias_method :authority, :host
11
12
 
12
13
  def connection
13
14
  @headers['connection']
@@ -52,13 +53,16 @@ module Qeweney
52
53
  def query
53
54
  return @query if @query
54
55
 
55
- @query = (q = uri.query) ? split_query_string(q) : {}
56
+ @query = (q = uri.query) ? parse_query(q) : {}
56
57
  end
57
58
 
58
- def split_query_string(query)
59
+ QUERY_KV_REGEXP = /([^=]+)(?:=(.*))?/
60
+
61
+ def parse_query(query)
59
62
  query.split('&').each_with_object({}) do |kv, h|
60
- k, v = kv.split('=')
61
- h[k.to_sym] = URI.decode_www_form_component(v)
63
+ k, v = kv.match(QUERY_KV_REGEXP)[1..2]
64
+ # k, v = kv.split('=')
65
+ h[k.to_sym] = v ? URI.decode_www_form_component(v) : true
62
66
  end
63
67
  end
64
68
 
@@ -74,6 +74,7 @@ module Qeweney
74
74
  end
75
75
 
76
76
  mime_type = Qeweney::MimeTypes[File.extname(path)]
77
+ opts[:stat] = stat
77
78
  (opts[:headers] ||= {})['Content-Type'] ||= mime_type if mime_type
78
79
 
79
80
  respond_with_static_file(full_path, etag, last_modified, opts)
@@ -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.2'
4
+ VERSION = '0.10'
5
5
  end
@@ -13,12 +13,31 @@ 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
32
+ assert_nil r.authority
19
33
 
20
34
  r = Qeweney.mock('host' => 'my.example.com')
21
35
  assert_equal 'my.example.com', r.host
36
+ assert_equal 'my.example.com', r.authority
37
+
38
+ r = Qeweney.mock(':authority' => 'my.foo.com')
39
+ assert_equal 'my.foo.com', r.host
40
+ assert_equal 'my.foo.com', r.authority
22
41
  end
23
42
 
24
43
  def test_full_uri
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.2
4
+ version: '0.10'
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-17 00:00:00.000000000 Z
11
+ date: 2021-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils