Skip to content

Commit 73fbbc7

Browse files
committed
fix: pattern matching in User context helpers
1 parent 5910d73 commit 73fbbc7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/algora/accounts/schemas/user.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,14 @@ defmodule Algora.Accounts.User do
303303
defp type_from_provider(:github, "Organization"), do: :organization
304304
defp type_from_provider(:github, _), do: :individual
305305

306-
def handle(%{handle: handle}), do: handle
306+
def handle(%{handle: handle}) when is_binary(handle), do: handle
307307
def handle(%{provider_login: handle}), do: handle
308308

309-
def url(%{handle: handle, type: :individual}), do: "/@/#{handle}"
309+
def url(%{handle: handle, type: :individual}) when is_binary(handle), do: "/@/#{handle}"
310310
def url(%{handle: handle, type: :organization}), do: "/org/#{handle}"
311311
def url(%{provider_login: handle}), do: "https://github.com/#{handle}"
312312

313-
def last_context(%{last_context: nil}), do: default_context()
314-
def last_context(%{last_context: last_context}), do: last_context
313+
def last_context(%{last_context: last_context}), do: last_context || default_context()
315314

316315
def default_context, do: "personal"
317316
end

0 commit comments

Comments
 (0)