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
11
11
alias Algora.MoneyUtils
12
12
alias Algora.Organizations.Member
13
13
alias Algora.Types.Money
14
+ alias Algora.Util
14
15
alias Algora.Workspace.Installation
15
16
alias AlgoraWeb.Endpoint
16
17
@@ -321,16 +322,16 @@ defmodule Algora.Accounts.User do
321
322
def get_domain ( % { "type" => type } ) when type != "Organization" , do: nil
322
323
323
324
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 ( )
325
326
326
327
if not Algora.Crawler . blacklisted? ( domain ) , do: domain
327
328
end
328
329
329
330
def get_domain ( % { "blog" => url } ) when is_binary ( url ) do
330
331
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 ) ,
332
333
% URI { host: host } when is_binary ( host ) and host != "" <- URI . parse ( url ) do
333
- host
334
+ Util . to_domain ( host )
334
335
else
335
336
_ -> nil
336
337
end
Original file line number Diff line number Diff line change @@ -182,6 +182,15 @@ defmodule Algora.Util do
182
182
end
183
183
end
184
184
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
+
185
194
def get_gravatar_url ( email , opts \\ [ ] ) do
186
195
default = Keyword . get ( opts , :default , "" )
187
196
size = Keyword . get ( opts , :size , 460 )
You can’t perform that action at this time.
0 commit comments