diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 4010bb5..de8848b 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -6,8 +6,6 @@ name: Elixir CI on: - push: - branches: ["main"] pull_request: branches: ["main"] diff --git a/lib/binoculo/cross_saver.ex b/lib/binoculo/cross_saver.ex index 6f72fc7..0c83ae8 100644 --- a/lib/binoculo/cross_saver.ex +++ b/lib/binoculo/cross_saver.ex @@ -15,7 +15,7 @@ defmodule Binoculo.CrossSaver do |> save_to_file() end - defp save_to_file_enabled?(), do: String.trim(System.get_env("SAVE_TO_FILE")) + defp save_to_file_enabled?(), do: true defp save_to_file(response) when is_binary(response) do String.to_atom(response) diff --git a/lib/binoculo/util.ex b/lib/binoculo/util.ex index ba8beed..6c4c2f1 100644 --- a/lib/binoculo/util.ex +++ b/lib/binoculo/util.ex @@ -54,9 +54,19 @@ defmodule Binoculo.Util do [http_code | key_value] = String.split(header_and_body[:header], "\r\n") resp = - for session <- key_value, into: %{} do - [key, value] = String.split(session, ": ", parts: 2) - {key, value} + if key_value not in [[], [""], nil] do + for session <- key_value, into: %{} do + session = unless String.contains?(session, ": ") do + session <> ": " + else + session + end + + [key, value] = String.split(session, ": ", parts: 2) + {key, value} + end + else + %{} end Map.put( @@ -79,7 +89,7 @@ defmodule Binoculo.Util do """ end - defp parse_header_and_body(http_response) do + def parse_header_and_body(http_response) do case String.split(http_response, "\r\n\r\n") do [header, body] -> %{header: header, body: body} header -> %{header: Enum.at(header, 0), body: nil}