File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -340,21 +340,22 @@ defmodule PlausibleWeb.Api.ExternalSitesController do
340340 % { "error" => error_msg }
341341 end
342342
343- defp expect_param_key ( params , key , inclusion \\ [ ] ) do
344- case Map . get ( params , key ) do
345- nil ->
346- { :missing , key }
343+ defp expect_param_key ( params , key , inclusion \\ [ ] )
347344
348- res ->
349- if Enum . empty? ( inclusion ) do
350- { :ok , res }
351- else
352- if res in inclusion do
353- { :ok , res }
354- else
355- { :missing , key }
356- end
357- end
345+ defp expect_param_key ( params , key , [ ] ) do
346+ case Map . fetch ( params , key ) do
347+ :error -> { :missing , key }
348+ res -> res
349+ end
350+ end
351+
352+ defp expect_param_key ( params , key , inclusion ) do
353+ case expect_param_key ( params , key , [ ] ) do
354+ { :ok , value } = ok ->
355+ if value in inclusion , do: ok , else: { :missing , key }
356+
357+ _ ->
358+ { :missing , key }
358359 end
359360 end
360361end
You can’t perform that action at this time.
0 commit comments