Skip to content

Commit

Permalink
fix: correctly merge and deduplicate headers on fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed Apr 28, 2024
1 parent fa6ab1c commit 1d514da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/supabase/fetcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ defmodule Supabase.Fetcher do
body: binary | nil | {:stream, Enumerable.t()},
headers: list(tuple)
def new_connection(method, url, body, headers) do
headers = merge_headers(default_headers(), headers)
headers = merge_headers(headers, default_headers())
Finch.build(method, url, headers, body)
end

@spec default_headers :: list(tuple)
defp default_headers do
[
{"content-type", "application/json"},
{"accept", "application/json"},
{"x-client-info", "supabase-fetch-elixir/#{version()}"}
{"x-client-info", "supabase-fetch-elixir/#{version()}"},
{"user-agent", "SupabasePotion/#{version()}"}
]
end

Expand Down Expand Up @@ -279,7 +281,7 @@ defmodule Supabase.Fetcher do

some
|> Kernel.++(other)
|> Enum.dedup_by(fn {name, _} -> name end)
|> Enum.uniq_by(fn {name, _} -> name end)
|> Enum.reject(fn {_, v} -> is_nil(v) end)
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Supabase.Potion.MixProject do
use Mix.Project

@version "0.3.5"
@version "0.3.6"
@source_url "https://github.com/zoedsoupe/supabase"

def project do
Expand Down

0 comments on commit 1d514da

Please sign in to comment.