qeweney 0.13.1 → 0.14

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: 54e76d6fe9d2c6490b00db19756306242b78465041f25e5771bedd630b6ad542
4
- data.tar.gz: 791acd0d69d9a3d95d62e207127829a3509986870ffcf94bd1690ebc37a76ea0
3
+ metadata.gz: 3f515f9637f0d993c9dfbea4d425695f76915871ad0c62e090cbb31a4a57b4a7
4
+ data.tar.gz: 80a6bf6da6a0d2b85771deff0cb24ad9bcf389e4af37042a6fd62c215617a657
5
5
  SHA512:
6
- metadata.gz: 7717cd77a46b8c13f496dcbeadf34af9ee7b5ba9173f8d3c638b46dc1cbdaabbda20045d59bb4a33b843145baf426ecc484df3b5ab9f018e5c9566116d4d4232
7
- data.tar.gz: e42853c551362e72fff6a51be7f236fd958a26e4415c6b924022ea711ac10058a56864051fc542f3eb0c926a0013af8fbb30451235bac949dadfd6bc4255d15e
6
+ metadata.gz: d08170e772a3fad93d49a06bc8ee6c656e5057e5368d3dfba6687d1f838dff50e7cfb8895315480f3f85ea519d8ee0ae20a3a480ee26293bd86bfec2c4912918
7
+ data.tar.gz: a1918424e95a70891eb4f8fb1b163cdf62167bb3847c16192be9f8dffd95c77513cca4f0e6d4a759275b14bc7891d770585b3625b4601177195ade7a731f6814
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.14 2021-08-10
2
+
3
+ - Fix Request#on with paths containing slashes
4
+
1
5
  ## 0.13.1 2021-08-03
2
6
 
3
7
  - Fix `Request#read`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.13)
4
+ qeweney (0.14)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -164,6 +164,8 @@ module Qeweney
164
164
  MAX_PARAMETER_VALUE_SIZE = 2**20 # 1MB
165
165
 
166
166
  def parse_urlencoded_form_data(body)
167
+ return {} unless body
168
+
167
169
  body.force_encoding(Encoding::UTF_8) unless body.encoding == Encoding::UTF_8
168
170
  body.split('&').each_with_object({}) do |i, m|
169
171
  raise 'Invalid parameter format' unless i =~ PARAMETER_RE
@@ -29,22 +29,24 @@ module Qeweney
29
29
  @path_parts.empty? ? '/' : "/#{@path_parts[@path_parts_idx..-1].join('/')}"
30
30
  end
31
31
 
32
- def enter_route
33
- @path_parts_idx += 1
32
+ def enter_route(depth = 1)
33
+ @path_parts_idx += depth
34
34
  end
35
35
 
36
- def leave_route
37
- @path_parts_idx -= 1
36
+ def leave_route(depth = 1)
37
+ @path_parts_idx -= depth
38
38
  end
39
39
 
40
- def on(route = nil, &block)
41
- if route
42
- return unless @path_parts[@path_parts_idx] == route
43
- end
40
+ def on(route, &block)
41
+ return route_found(&block) unless route
42
+
43
+ route_parts = route.split('/')
44
+ route_length = route_parts.size
45
+ return unless @path_parts[@path_parts_idx, route_length] == route_parts
44
46
 
45
- enter_route
47
+ enter_route(route_length)
46
48
  route_found(&block)
47
- leave_route
49
+ leave_route(route_length)
48
50
  end
49
51
 
50
52
  def is(route = '/', &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qeweney
4
- VERSION = '0.13.1'
4
+ VERSION = '0.14'
5
5
  end
data/test/test_routing.rb CHANGED
@@ -114,4 +114,16 @@ class RoutingTest < MiniTest::Test
114
114
  assert_equal '/baz/d/e/f', default_relative_path
115
115
  assert_equal [[:respond, r, '/d/e/f', {}]], r.response_calls
116
116
  end
117
+
118
+ def test_well_known
119
+ app = Qeweney.route do |r|
120
+ r.on('.well-known/acme-challenge') { r.respond(r.route_relative_path) }
121
+ r.default { r.respond('not found') }
122
+ end
123
+
124
+ r = Qeweney.mock(':path' => '/.well-known/acme-challenge/foo')
125
+ app.(r)
126
+ assert_equal [[:respond, r, '/foo', {}]], r.response_calls
127
+ end
117
128
  end
129
+
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.13.1
4
+ version: '0.14'
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-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils