routing-filter-codeur 0.7.1 → 0.7.1.2

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: 2fbac8b40f1dff948e041a361199cab68a9a8a83315cb3d9fcbb3d8205e601b9
4
- data.tar.gz: c111675e27ec88cc482ee489c7a871f5954f0d9ec005789f10396435b6830d76
3
+ metadata.gz: 0d471f2df5df783d7ff49326fddeb891cd698f580e48044945e969fc9d65e105
4
+ data.tar.gz: 938019b4ade919fd8d8291c89bb9b309dd9f3afa0870ca9b3a225739911347fe
5
5
  SHA512:
6
- metadata.gz: 88931be45d8c5e2506ef3e81961cbf44e462668b360ee693cfc27e2350489ecf62e17ec59b8807804501590309bc98bbf86b32332359ae29916cc7ff70c222de
7
- data.tar.gz: 34a5216a13077f27e10e362a7a0a820b2c09fae28c3f0aaf19bdf91591faea04469b331cca00eabce1e001406d002362b48babae1f5846c6289336dd1a3ae1ce
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'
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
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