File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ defmodule Algora.Accounts.User do
1111 alias Algora.MoneyUtils
1212 alias Algora.Organizations.Member
1313 alias Algora.Types.Money
14+ alias Algora.Util
1415 alias Algora.Workspace.Installation
1516 alias AlgoraWeb.Endpoint
1617
@@ -321,16 +322,16 @@ defmodule Algora.Accounts.User do
321322 def get_domain ( % { "type" => type } ) when type != "Organization" , do: nil
322323
323324 def get_domain ( % { "email" => email } ) when is_binary ( email ) do
324- domain = email |> String . split ( "@" ) |> List . last ( )
325+ domain = email |> String . split ( "@" ) |> List . last ( ) |> Util . to_domain ( )
325326
326327 if not Algora.Crawler . blacklisted? ( domain ) , do: domain
327328 end
328329
329330 def get_domain ( % { "blog" => url } ) when is_binary ( url ) do
330331 domain =
331- with url when not is_nil ( url ) <- Algora. Util. normalize_url ( url ) ,
332+ with url when not is_nil ( url ) <- Util . normalize_url ( url ) ,
332333 % URI { host: host } when is_binary ( host ) and host != "" <- URI . parse ( url ) do
333- host
334+ Util . to_domain ( host )
334335 else
335336 _ -> nil
336337 end
Original file line number Diff line number Diff line change @@ -182,6 +182,15 @@ defmodule Algora.Util do
182182 end
183183 end
184184
185+ def to_domain ( nil ) , do: nil
186+
187+ def to_domain ( url ) do
188+ url
189+ |> String . trim_leading ( "https://" )
190+ |> String . trim_leading ( "http://" )
191+ |> String . trim_leading ( "www." )
192+ end
193+
185194 def get_gravatar_url ( email , opts \\ [ ] ) do
186195 default = Keyword . get ( opts , :default , "" )
187196 size = Keyword . get ( opts , :size , 460 )
You can’t perform that action at this time.
0 commit comments