diff --git a/lib/elixir_auth_google.ex b/lib/elixir_auth_google.ex index 15d8363..73c591c 100644 --- a/lib/elixir_auth_google.ex +++ b/lib/elixir_auth_google.ex @@ -26,10 +26,15 @@ defmodule ElixirAuthGoogle do `get_baseurl_from_conn/1` derives the base URL from the conn struct """ @spec get_baseurl_from_conn(conn) :: String.t() - def get_baseurl_from_conn(%{host: h, port: p, scheme: s}) when p != 80 do - "#{Atom.to_string(s)}://#{h}:#{p}" + def get_baseurl_from_conn(%{host: h, port: p, scheme: s}) do + cond do + p == 443 -> "#{Atom.to_string(s)}://#{h}" + p == 80 -> "#{Atom.to_string(s)}://#{h}" + true -> "#{Atom.to_string(s)}://#{h}:#{p}" + end end + def get_baseurl_from_conn(%{host: h, scheme: s}) do "#{Atom.to_string(s)}://#{h}" end