Skip to content

Commit

Permalink
Tweak AD::Http::FilterParameters code example [ci-skip]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathanhefner committed Nov 15, 2022
1 parent 8b216e8 commit 782bed5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions actionpack/lib/action_dispatch/http/filter_parameters.rb
Expand Up @@ -12,25 +12,25 @@ module Http
# sub-hashes are passed to it, where the value or the key can be replaced using
# <tt>String#replace</tt> or similar methods.
#
# # Replaces values with "[FILTERED]" for keys that match /password/i.
# env["action_dispatch.parameter_filter"] = [:password]
# => replaces the value to all keys matching /password/i with "[FILTERED]"
#
# # Replaces values with "[FILTERED]" for keys that match /foo|bar/i.
# env["action_dispatch.parameter_filter"] = [:foo, "bar"]
# => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
#
# env["action_dispatch.parameter_filter"] = [ /\Apin\z/i, /\Apin_/i ]
# => replaces the value for the exact (case-insensitive) key 'pin' and all
# (case-insensitive) keys beginning with 'pin_', with "[FILTERED]"
# Does not match keys with 'pin' as a substring, such as 'shipping_id'.
# # Replaces values for the exact key "pin" and for keys that begin with
# # "pin_". Does not match keys that otherwise include "pin" as a
# # substring, such as "shipping_id".
# env["action_dispatch.parameter_filter"] = [ /\Apin\z/, /\Apin_/ ]
#
# # Replaces the value for :code in `{ credit_card: { code: "xxxx" } }`.
# # Does not change `{ file: { code: "xxxx" } }`.
# env["action_dispatch.parameter_filter"] = [ "credit_card.code" ]
# => replaces { credit_card: {code: "xxxx"} } with "[FILTERED]", does not
# change { file: { code: "xxxx"} }
#
# # Reverses values for keys that match /secret/i.
# env["action_dispatch.parameter_filter"] = -> (k, v) do
# v.reverse! if k.match?(/secret/i)
# end
# => reverses the value to all keys matching /secret/i
module FilterParameters
ENV_MATCH = [/RAW_POST_DATA/, "rack.request.form_vars"] # :nodoc:
NULL_PARAM_FILTER = ActiveSupport::ParameterFilter.new # :nodoc:
Expand Down

0 comments on commit 782bed5

Please sign in to comment.