diff --git a/lib/bypass/instance.ex b/lib/bypass/instance.ex index f8ae2b1..74bfe2e 100644 --- a/lib/bypass/instance.ex +++ b/lib/bypass/instance.ex @@ -4,7 +4,7 @@ defmodule Bypass.Instance do use GenServer, restart: :transient import Bypass.Utils - import Plug.Router.Utils, only: [build_path_match: 1] + import Plug.Router.Utils, only: [build_path_match: 1, split: 1] def start_link(opts \\ []) do GenServer.start_link(__MODULE__, [opts]) @@ -297,7 +297,7 @@ defmodule Bypass.Instance do end defp route_info(method, path, %{expectations: expectations} = _state) do - segments = build_path_match(path) |> elem(1) + segments = path |> split route = expectations diff --git a/test/bypass_test.exs b/test/bypass_test.exs index 8c26cc8..71ec7d0 100644 --- a/test/bypass_test.exs +++ b/test/bypass_test.exs @@ -643,4 +643,15 @@ defmodule BypassTest do Bypass.open(:error) end end + + test "path can contain colon" do + bypass = Bypass.open() + + Bypass.expect(bypass, "POST", "/resources/:resource", fn conn -> + assert conn.params == %{ "resource" => ":resource" } + Plug.Conn.send_resp(conn, 200, "") + end) + + assert {:ok, 200, ""} = request(bypass.port, "/resources/:resource") + end end