- defp call_static(conn, opts, from) do
- opts =
- opts
- |> Map.put(:from, from)
+ def preferred_or_fallback(_conn, fallback), do: fallback
+
+ defp enabled?(if_opt) when is_function(if_opt), do: if_opt.()
+ defp enabled?(true), do: true
+ defp enabled?(_), do: false
+
+ defp invalid_path?(list) do
+ invalid_path?(list, :binary.compile_pattern(["/", "\\", ":", "\0"]))
+ end
+
+ defp invalid_path?([h | _], _match) when h in [".", "..", ""], do: true
+ defp invalid_path?([h | t], match), do: String.contains?(h, match) or invalid_path?(t)
+ defp invalid_path?([], _match), do: false
+
+ defp api_route?([]), do: false