diff --git a/cask/src/cask/main/Main.scala b/cask/src/cask/main/Main.scala index 31fd1522b2..7687eafe06 100644 --- a/cask/src/cask/main/Main.scala +++ b/cask/src/cask/main/Main.scala @@ -99,7 +99,7 @@ object Main{ (r: Any) => Main.writeResponse(exchange, r.asInstanceOf[Response.Raw]) ) - dispatchTrie.lookup(Util.splitPath(exchange.getRequestPath).toList, Map()) match { + dispatchTrie.lookup(Util.splitPath(java.net.URLDecoder.decode(exchange.getRequestURI, "UTF-8")).toList, Map()) match { case None => Main.writeResponse(exchange, handleNotFound()) case Some((methodMap, routeBindings, remaining)) => methodMap.get(effectiveMethod) match { diff --git a/example/queryParams/app/test/src/ExampleTests.scala b/example/queryParams/app/test/src/ExampleTests.scala index c0f8466df1..bf814cdeb1 100644 --- a/example/queryParams/app/test/src/ExampleTests.scala +++ b/example/queryParams/app/test/src/ExampleTests.scala @@ -21,10 +21,10 @@ object ExampleTests extends TestSuite{ val noIndexPage = requests.get(host, check = false) noIndexPage.statusCode ==> 404 - assert( - requests.get(s"$host/article/123?param=xyz").text() == - "Article 123 xyz" - ) + requests.get(s"$host/article/123?param=xyz").text() ==> "Article 123 xyz" + + requests.get(s"$host/article/123?param=1+%2B+1+%3D+2%25%3F%26").text() ==> + "Article 123 1 + 1 = 2%?&" requests.get(s"$host/article/123", check = false).text() ==> """Missing argument: (param: String) diff --git a/example/variableRoutes/app/test/src/ExampleTests.scala b/example/variableRoutes/app/test/src/ExampleTests.scala index 1d2d9378bf..78a9fb7b0a 100644 --- a/example/variableRoutes/app/test/src/ExampleTests.scala +++ b/example/variableRoutes/app/test/src/ExampleTests.scala @@ -22,6 +22,8 @@ object ExampleTests extends TestSuite{ noIndexPage.statusCode ==> 404 requests.get(s"$host/user/lihaoyi").text() ==> "User lihaoyi" + requests.get(s"$host/user/li+haoyi").text() ==> "User li haoyi" + requests.get(s"$host/user/1+%2B+1+%3D+2%25%3F%26").text() ==> "User 1 + 1 = 2%?&" requests.get(s"$host/user", check = false).statusCode ==> 404