Skip to content

Commit ebddd25

Browse files
committed
Normalize route verb while grouping
1 parent 2fd3f46 commit ebddd25

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

lib/phoenix/router.ex

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,10 @@ defmodule Phoenix.Router do
615615
validate_group_by_verb!(routes_exprs, env)
616616

617617
routes_exprs
618-
|> Enum.group_by(&elem(&1, 0).verb)
619-
|> Map.pop(:*, [])
618+
|> Enum.group_by(&(elem(&1, 0).verb |> to_string() |> String.upcase(:ascii)))
619+
|> Map.pop("*", [])
620620
|> then(fn {match_routes_exprs, map} ->
621-
Map.to_list(map) ++ [{:*, match_routes_exprs}]
621+
Map.to_list(map) ++ [{"*", match_routes_exprs}]
622622
end)
623623
|> Enum.map_reduce({[], %{}}, &build_match_verb/2)
624624
end
@@ -681,7 +681,7 @@ defmodule Phoenix.Router do
681681
"""
682682
end
683683

684-
defp build_match_verb({:*, routes_exprs}, acc) do
684+
defp build_match_verb({"*", routes_exprs}, acc) do
685685
name = :__match_route_catch_all__
686686

687687
{clauses, acc} =
@@ -705,7 +705,6 @@ defmodule Phoenix.Router do
705705
end
706706

707707
defp build_match_verb({verb, routes_exprs}, acc) do
708-
pattern = verb |> to_string() |> String.upcase()
709708
name = :"__match_route_#{verb}__"
710709

711710
{clauses, acc} =
@@ -719,7 +718,7 @@ defmodule Phoenix.Router do
719718
__match_route_catch_all__(path, host)
720719
end
721720

722-
def __match_route__(unquote(pattern), path, host) do
721+
def __match_route__(unquote(verb), path, host) do
723722
unquote(name)(path, host)
724723
end
725724
end

0 commit comments

Comments
 (0)