Dialyzer gives no warnings for the possible List getting returned, the ''.
defmodule PublicLaw.Tenant do
@moduledoc """
Functions for handing the Multi/Single-Tenant scheme.
"""
@doc """
Return the subdomain in the HTTP request, or empty string if none.
Assumes that the hostname is one of two forms:
* nevada.public.law
* public.law
"""
@spec subdomain(Plug.Conn) :: binary()
def subdomain(conn) do
case String.split(conn.host, ".") do
[subd, _domain, _tld] ->
subd
_ ->
''
end
end
end