Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/phoenix_live_view/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,14 @@ defmodule Phoenix.LiveView.Utils do
# Returns the lowercased URI scheme of `to` if it begins with one, that is, a
# ":" appears before any "/", "?" or "#"; otherwise returns nil. This avoids
# treating a colon in a path segment, query, or fragment as a scheme.
defp uri_scheme("/" <> _to), do: nil

defp uri_scheme(to) do
case :binary.match(to, [":", "/", "?", "#"]) do
{pos, 1} ->
if binary_part(to, pos, 1) == ":",
do: String.downcase(binary_part(to, 0, pos), :ascii),
else: nil
{pos, 1} when binary_part(to, pos, 1) == ":" ->
String.downcase(binary_part(to, 0, pos), :ascii)

:nomatch ->
_ ->
nil
end
end
Expand Down
Loading