routing-filter-codeur 0.7.1.1 → 0.7.1.2

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: d82978a3445a6164bddffdf0d98fe25cc425ecdf523cfe8ee4b47a3e64bbdb39
4
- data.tar.gz: 150ad70a72b7bccd9258ca8db48155da90b9b6f6b2fb034c49a64543bc40b12e
3
+ metadata.gz: 0d471f2df5df783d7ff49326fddeb891cd698f580e48044945e969fc9d65e105
4
+ data.tar.gz: 938019b4ade919fd8d8291c89bb9b309dd9f3afa0870ca9b3a225739911347fe
5
5
  SHA512:
6
- metadata.gz: afdec861ddbc9ee114a3fea0a742d75e078a2b65885e518025af865037a5adec24f2109facf53dafaa550ed83de7c799a61525a8d969a3c96d8c928fc866e153
7
- data.tar.gz: 6503ef8d3b9983e9d62ad4f633bf3122949fa47b12e4a5f415f702dbe993184aa40571192ad8bf68111b1d4b41c343bc3e4d4245ce62f33df2627160d367aa64
6
+ metadata.gz: 3524f4dca5e3a1a90aff4a04cb6b68581bad7b17c454d7e214ce86f9d8fb1501a495c6d37ba40d57b357d07232acdb2119de18c208389ea8572c95088df8db35
7
+ data.tar.gz: c35b8a1711a4904cae16562fb9df5181d66baff0a020a43805f7835474235ec222e8f50187dca2e26401512250f1b9859eb92de581fb7b5a1e15afbe57328a29
@@ -1,25 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Prepend the method lookup to intercept find_routes in rails.
4
+ #
5
+ # This enables us to intercept the incoming route paths before they are
6
+ # recognized by the rails router and transformed to a route set and dispatched
7
+ # to a controller.
1
8
  module ActionDispatchJourneyRouterWithFiltering
2
9
  def find_routes(env)
3
- path = env.is_a?(Hash) ? env['PATH_INFO'] : env.path_info
10
+ path = if env.is_a?(Hash)
11
+ env['PATH_INFO']
12
+ else
13
+ env.path_info
14
+ end
15
+
4
16
  filter_parameters = {}
5
17
  original_path = path.dup
6
18
 
19
+ # Apply the custom user around_recognize filter callbacks
7
20
  @routes.filters.run(:around_recognize, path, env) do
21
+ # Yield the filter paramters for adjustment by the user
8
22
  filter_parameters
9
23
  end
10
24
 
11
- super(env).map do | route|
12
- env.parameters.merge(filter_parameters)
13
- [ route ]
14
- end.tap do |route|
15
- # restore the original path
25
+ # Recognize the routes
26
+ super(env) do |match, parameters, route|
27
+ # Merge in custom parameters that will be visible to the controller
28
+ params = (parameters || {}).merge(filter_parameters)
29
+
30
+ # Reset the path before yielding to the controller (prevents breakages in CSRF validation)
16
31
  if env.is_a?(Hash)
17
32
  env['PATH_INFO'] = original_path
18
33
  else
19
34
  env.path_info = original_path
20
35
  end
36
+
37
+ # Yield results are dispatched to the controller
38
+ yield [match, params, route]
21
39
  end
22
40
  end
23
41
  end
24
42
 
25
- ActionDispatch::Journey::Router.send(:prepend, ActionDispatchJourneyRouterWithFiltering)
43
+ ActionDispatch::Journey::Router.prepend(ActionDispatchJourneyRouterWithFiltering)
@@ -1,3 +1,3 @@
1
1
  module RoutingFilter
2
- VERSION = '0.7.1.1'
2
+ VERSION = '0.7.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routing-filter-codeur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1.1
4
+ version: 0.7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-15 00:00:00.000000000 Z
12
+ date: 2024-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack