Skip to content

Commit 059024e

Browse files
authored
Merge pull request rails#41260 from inopinatus/filter_parameters_doc
Add example of the regexp parameter filter type [ci skip]
2 parents a205f51 + 36895d2 commit 059024e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

actionpack/lib/action_dispatch/http/filter_parameters.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ module Http
1818
# env["action_dispatch.parameter_filter"] = [:foo, "bar"]
1919
# => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
2020
#
21+
# env["action_dispatch.parameter_filter"] = [ /\Apin\z/i, /\Apin_/i ]
22+
# => replaces the value for the exact (case-insensitive) key 'pin' and all
23+
# (case-insensitive) keys beginning with 'pin_', with "[FILTERED]"
24+
# Does not match keys with 'pin' as a substring, such as 'shipping_id'.
25+
#
2126
# env["action_dispatch.parameter_filter"] = [ "credit_card.code" ]
2227
# => replaces { credit_card: {code: "xxxx"} } with "[FILTERED]", does not
2328
# change { file: { code: "xxxx"} }

activesupport/lib/active_support/parameter_filter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ module ActiveSupport
1616
# ActiveSupport::ParameterFilter.new([:foo, "bar"])
1717
# => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
1818
#
19+
# ActiveSupport::ParameterFilter.new([/\Apin\z/i, /\Apin_/i])
20+
# => replaces the value for the exact (case-insensitive) key 'pin' and all
21+
# (case-insensitive) keys beginning with 'pin_', with "[FILTERED]".
22+
# Does not match keys with 'pin' as a substring, such as 'shipping_id'.
23+
#
1924
# ActiveSupport::ParameterFilter.new(["credit_card.code"])
2025
# => replaces { credit_card: {code: "xxxx"} } with "[FILTERED]", does not
2126
# change { file: { code: "xxxx"} }

0 commit comments

Comments
 (0)