Skip to content

Commit 782bed5

Browse files
Tweak AD::Http::FilterParameters code example [ci-skip]
Prior to this commit, the format of the code example confused the syntax highlighter. This commit formats each explanation as a code comment, and tweaks their wording for clarity.
1 parent 8b216e8 commit 782bed5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

actionpack/lib/action_dispatch/http/filter_parameters.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ module Http
1212
# sub-hashes are passed to it, where the value or the key can be replaced using
1313
# <tt>String#replace</tt> or similar methods.
1414
#
15+
# # Replaces values with "[FILTERED]" for keys that match /password/i.
1516
# env["action_dispatch.parameter_filter"] = [:password]
16-
# => replaces the value to all keys matching /password/i with "[FILTERED]"
1717
#
18+
# # Replaces values with "[FILTERED]" for keys that match /foo|bar/i.
1819
# env["action_dispatch.parameter_filter"] = [:foo, "bar"]
19-
# => 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'.
21+
# # Replaces values for the exact key "pin" and for keys that begin with
22+
# # "pin_". Does not match keys that otherwise include "pin" as a
23+
# # substring, such as "shipping_id".
24+
# env["action_dispatch.parameter_filter"] = [ /\Apin\z/, /\Apin_/ ]
2525
#
26+
# # Replaces the value for :code in `{ credit_card: { code: "xxxx" } }`.
27+
# # Does not change `{ file: { code: "xxxx" } }`.
2628
# env["action_dispatch.parameter_filter"] = [ "credit_card.code" ]
27-
# => replaces { credit_card: {code: "xxxx"} } with "[FILTERED]", does not
28-
# change { file: { code: "xxxx"} }
2929
#
30+
# # Reverses values for keys that match /secret/i.
3031
# env["action_dispatch.parameter_filter"] = -> (k, v) do
3132
# v.reverse! if k.match?(/secret/i)
3233
# end
33-
# => reverses the value to all keys matching /secret/i
3434
module FilterParameters
3535
ENV_MATCH = [/RAW_POST_DATA/, "rack.request.form_vars"] # :nodoc:
3636
NULL_PARAM_FILTER = ActiveSupport::ParameterFilter.new # :nodoc:

0 commit comments

Comments
 (0)