From 7ada2f1854563852c615eec681c67f80f135ade5 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Mar 2024 22:32:49 +0100 Subject: [PATCH] make compatible with rails 7.1 (most likely will break for previous versions --- lib/routing_filter/adapters/routers/journey.rb | 9 +++++---- routing-filter.gemspec | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/routing_filter/adapters/routers/journey.rb b/lib/routing_filter/adapters/routers/journey.rb index 39b7a3a..ad8f718 100644 --- a/lib/routing_filter/adapters/routers/journey.rb +++ b/lib/routing_filter/adapters/routers/journey.rb @@ -8,15 +8,16 @@ def find_routes(env) filter_parameters end - super(env).map do |match, parameters, route| - [ match, parameters.merge(filter_parameters), route ] - end.tap do |match, parameters, route| - # restore the original path + super(env) do |match, parameters, route| + parameters = parameters.merge(filter_parameters) + if env.is_a?(Hash) env['PATH_INFO'] = original_path else env.path_info = original_path end + + yield [match, parameters, route] end end end diff --git a/routing-filter.gemspec b/routing-filter.gemspec index 804f2ea..0496b0e 100644 --- a/routing-filter.gemspec +++ b/routing-filter.gemspec @@ -1,7 +1,7 @@ $:.unshift File.expand_path('../lib', __FILE__) require 'routing_filter/version' -rails_version = ['>= 6.1'] +rails_version = ['>= 7.1'] Gem::Specification.new do |s| s.name = "routing-filter"