Genie.jl
Genie.jl copied to clipboard
Routes don’t decode the Unicode characters of encoded URLs
MWE:
using Genie
using Genie.Renderer.Json
using Genie.Requests
using Genie.Router
using HTTP
using JSON3
route("/api/réception", method = POST) do
message = jsonpayload()
(:echo => (message["message"] * " ") ^ message["repeat"]) |> json
end
Case 1
route("/api/émission") do
response = HTTP.request("POST", "http://localhost:8000/api/réception", [("Content-Type", "application/json")], """{"message":"hello", "repeat":3}""")
response.body |> String |> JSON3.read |> json
end
Case 2
route("/api/emission") do
response = HTTP.request("POST", "http://localhost:8000/api/réception", [("Content-Type", "application/json")], """{"message":"hello", "repeat":3}""")
response.body |> String |> JSON3.read |> json
end
up()
Case 2 works well, but case 1 results in 404 Not Found Sorry, we can not find /api/%C3%A9mission
[ Info: POST /api/réception 200
[ Info: GET /api/emission 200
┌ Error: GET /api/%C3%A9mission 404
└ @ Genie.Router ~/.julia/packages/Genie/3nusr/src/Router.jl:200
Note: be careful because browsers will usually show you the real human-readable characters, but internally, they are escaped with % (as well as when you copy URLs from browser to text editor).