hanami-router 3.0.0 → 3.0.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
  SHA256:
3
- metadata.gz: 30cf4c77a2d61c1f8c8817c19db6bd5089627a6639dbda3f6b44441433516a67
4
- data.tar.gz: a79a9f499cbd4746adc14e70dd9aeff68aad669cbdb3109bab7501264e5930ab
3
+ metadata.gz: 14cb12bff3d06e4a6e678777f8cb63eaf47d1abf9ca5495a3db895ab52d9e370
4
+ data.tar.gz: 0a4873b2c4482bb91daf9020f01a1c58f0a1ad08ba031c1124467ef0488ca8f2
5
5
  SHA512:
6
- metadata.gz: d08ff095875e2e7a24d4b3663344e6aa0cb3de17bd41ed22c809588a361f28bc9f1f1ffd0ccd1933bb35c88b78a330bbfc9a4aa178cd661202657cae56ce6d13
7
- data.tar.gz: e6ca075b83151a66a015ba99c2120ee45bd35fe338cb4f7feb6d82e772eab60a8116ea4ee4fa90629c8e6e79cd2b17c867630916b9a5c3a0ac3154eabed1be77
6
+ metadata.gz: db37dc2d7625b90c7c81ec0fa7ed5d53ac7cf522a3aadfb26a4e48ebe2b4b0e12d11b2d8467657349a849bce66e1fbcf0721842827ffb2ef1940767f4fc16584
7
+ data.tar.gz: 1dc0954d1560d3ec6a82222d3f2b9c356261b588c90fdea3b2cd52ac1c4d5468564eb402e1c9134480e666a728bf152e68332bf70bc15319b812d74de7451271
data/CHANGELOG.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
7
6
 
8
7
  ## [Unreleased]
9
8
 
@@ -19,7 +18,16 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
19
18
 
20
19
  ### Security
21
20
 
22
- [Unreleased]: http://github.com/hanami/hanami-router/compare/v3.0.0...HEAD
21
+ [Unreleased]: http://github.com/hanami/hanami-router/compare/v3.0.1...HEAD
22
+
23
+ ## [3.0.1] - 2026-11-24
24
+
25
+ ### Security
26
+
27
+ - Apply a scope's middleware to all of its paths when it contains a nested scope or slice with its own middleware. Previously, paths in the outer scope that weren't in the nested scope skipped the outer scope's middleware, such as authentication. (@parndt in GHSA-73j7-6jvw-2v7g)
28
+ - - Stop concurrent requests to the same route from receiving each other's path params. Matching a route stored the captured params on the route itself, so a thread switch between matching and reading them could give one request another's params. (@parndt in GHSA-wgjv-fq27-94m7)
29
+
30
+ [3.0.1]: http://github.com/hanami/hanami-router/compare/v3.0.0...v3.0.1
23
31
 
24
32
  ## [3.0.0] - 2026-06-30
25
33
 
@@ -38,16 +38,19 @@ module Hanami
38
38
  # @since 2.0.0
39
39
  def find(path)
40
40
  node = @root
41
+ app = @root.app
41
42
 
43
+ # Track the deepest scope with an app on the way down. When the descent stops early (a
44
+ # segment with no matching child under a node that has children), the request is still
45
+ # within that scope, so its middleware must apply.
42
46
  for_each_segment(path) do |segment|
47
+ node = node.get(segment)
43
48
  break unless node
44
49
 
45
- node = node.get(segment)
50
+ app = node.app if node.app?
46
51
  end
47
52
 
48
- return node.app if node&.app?
49
-
50
- @root.app || @app
53
+ app || @app
51
54
  end
52
55
 
53
56
  # @api private
@@ -9,24 +9,24 @@ module Hanami
9
9
  #
10
10
  # @api private
11
11
  # @since 2.2.0
12
- attr_reader :to, :params, :matcher
12
+ attr_reader :to, :matcher
13
13
 
14
14
  # @api private
15
15
  # @since 2.2.0
16
16
  def initialize(route, to, constraints)
17
17
  @to = to
18
- @params = nil
19
18
  @matcher = Mustermann.new(route, type: :rails, version: "5.0", capture: constraints)
20
19
  end
21
20
 
21
+ # Returns the captured params for the given path, or nil if the path doesn't match.
22
+ #
23
+ # Leaves are shared across concurrent requests, so the captures are returned rather than
24
+ # stored on the leaf.
25
+ #
22
26
  # @api private
23
27
  # @since 2.2.0
24
28
  def match(path)
25
- match = matcher.match(path)
26
-
27
- @params = match.named_captures if match
28
-
29
- match
29
+ matcher.match(path)&.named_captures
30
30
  end
31
31
  end
32
32
  end
@@ -45,10 +45,17 @@ module Hanami
45
45
  @leaves << Leaf.new(route, to, constraints)
46
46
  end
47
47
 
48
+ # Returns the endpoint and captured params of the first leaf matching the given path, or nil.
49
+ #
48
50
  # @api private
49
51
  # @since 2.2.0
50
52
  def match(path)
51
- @leaves&.find { |leaf| leaf.match(path) }
53
+ @leaves&.each do |leaf|
54
+ params = leaf.match(path)
55
+ return [leaf.to, params] if params
56
+ end
57
+
58
+ nil
52
59
  end
53
60
 
54
61
  private
@@ -41,7 +41,7 @@ module Hanami
41
41
 
42
42
  return unless segments.all? { |segment| node = node.get(segment) }
43
43
 
44
- node.match(path)&.then { |found| [found.to, found.params] }
44
+ node.match(path)
45
45
  end
46
46
 
47
47
  private
@@ -7,6 +7,6 @@ module Hanami
7
7
  # @return [String]
8
8
  #
9
9
  # @api public
10
- VERSION = "3.0.0"
10
+ VERSION = "3.0.1"
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team