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 @@ -337,21 +337,22 @@ defmodule PlausibleWeb.Api.ExternalSitesController do
337337 % { "error" => error_msg }
338338 end
339339
340- defp expect_param_key ( params , key , inclusion \\ [ ] ) do
341- case Map . get ( params , key ) do
342- nil ->
343- { :missing , key }
340+ defp expect_param_key ( params , key , inclusion \\ [ ] )
344341
345- res ->
346- if Enum . empty? ( inclusion ) do
347- { :ok , res }
348- else
349- if res in inclusion do
350- { :ok , res }
351- else
352- { :missing , key }
353- end
354- end
342+ defp expect_param_key ( params , key , [ ] ) do
343+ case Map . fetch ( params , key ) do
344+ :error -> { :missing , key }
345+ res -> res
346+ end
347+ end
348+
349+ defp expect_param_key ( params , key , inclusion ) do
350+ case expect_param_key ( params , key , [ ] ) do
351+ { :ok , value } = ok ->
352+ if value in inclusion , do: ok , else: { :missing , key }
353+
354+ _ ->
355+ { :missing , key }
355356 end
356357 end
357358end
You can’t perform that action at this time.
0 commit comments