Skip to content

Commit

Permalink
[handler] Adding filter sensitive data to request url before compare …
Browse files Browse the repository at this point in the history
…in `ExVCR.Handler.match_by_url/3`
  • Loading branch information
gullitmiranda committed Jul 29, 2015
1 parent cf5585c commit 3321a1f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/exvcr/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ defmodule ExVCR.Handler do
end

defp match_by_url(response, keys, recorder_options) do
if stub_mode?(recorder_options) do
request_url = response[:request].url
key_url = to_string(keys[:url])
request_url = response[:request].url |> ExVCR.Filter.filter_sensitive_data
key_url = to_string(keys[:url])

if stub_mode?(recorder_options) do
if match = Regex.run(~r/~r\/(.+)\//, request_url) do
pattern = Regex.compile!(Enum.at(match, 1))
Regex.match?(pattern, key_url)
else
request_url == key_url
end
else
request_url = parse_url(response[:request].url, recorder_options)
key_url = parse_url(keys[:url], recorder_options)
request_url = parse_url(request_url, recorder_options)
key_url = parse_url(key_url, recorder_options)

request_url == key_url
end
Expand Down

0 comments on commit 3321a1f

Please sign in to comment.