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 +4 -4
- data/CHANGELOG.md +11 -3
- data/lib/hanami/middleware/trie.rb +7 -4
- data/lib/hanami/router/leaf.rb +7 -7
- data/lib/hanami/router/node.rb +8 -1
- data/lib/hanami/router/trie.rb +1 -1
- data/lib/hanami/router/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14cb12bff3d06e4a6e678777f8cb63eaf47d1abf9ca5495a3db895ab52d9e370
|
|
4
|
+
data.tar.gz: 0a4873b2c4482bb91daf9020f01a1c58f0a1ad08ba031c1124467ef0488ca8f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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
|
-
|
|
50
|
+
app = node.app if node.app?
|
|
46
51
|
end
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@root.app || @app
|
|
53
|
+
app || @app
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
# @api private
|
data/lib/hanami/router/leaf.rb
CHANGED
|
@@ -9,24 +9,24 @@ module Hanami
|
|
|
9
9
|
#
|
|
10
10
|
# @api private
|
|
11
11
|
# @since 2.2.0
|
|
12
|
-
attr_reader :to, :
|
|
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
|
-
|
|
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
|
data/lib/hanami/router/node.rb
CHANGED
|
@@ -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&.
|
|
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
|
data/lib/hanami/router/trie.rb
CHANGED