13 lines
319 B
Elixir
13 lines
319 B
Elixir
|
defmodule Aggiedit.Utils do
|
||
|
def get_email_domain(email) do
|
||
|
domain_split = Regex.named_captures(~r/^.*@(?<domain>.*)$/, email)["domain"]
|
||
|
|> String.downcase()
|
||
|
|> String.split(".")
|
||
|
|
||
|
if Enum.count(domain_split) >= 2 do
|
||
|
Enum.join(Enum.take(domain_split, -2), ".")
|
||
|
else
|
||
|
nil
|
||
|
end
|
||
|
end
|
||
|
end
|