Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/realtime/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ defmodule Realtime.Helpers do
iex> Realtime.Helpers.get_external_id("tenant.supabase.co")
{:ok, "tenant"}

iex> Realtime.Helpers.get_external_id("www.supabase.co")
{:error, :tenant_not_found_in_host}
iex> Realtime.Helpers.get_external_id("localhost")
{:ok, "localhost"}

"""

@spec get_external_id(String.t()) :: {:ok, String.t()} | {:error, atom()}
def get_external_id(host) when is_binary(host) do
case String.split(host, ".", parts: 2) do
[] -> {:error, :tenant_not_found_in_host}
[_] -> {:error, :tenant_not_found_in_host}
["www", _] -> {:error, :tenant_not_found_in_host}
[id] -> {:ok, id}
[id, _] -> {:ok, id}
end
end
Expand Down