sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

xavante loses url GET params #161

Open d9k opened 6 years ago

d9k commented 6 years ago

example:

http://127.0.0.1:8083/test/url_params?a=1&b=2

a and b params are NOT in page.GET table.

For the case of

http://127.0.0.1:8083/test/url_params&a=1&b=2

a and b params appear in page.GET table (but this url is wrong!).

d9k commented 6 years ago

start-server.lua:

for http://127.0.0.1:8083/test/url_params?a=1&b=2:

in function(req,res,cap):

> req.parsed_url
{authority = "127.0.0.1:8083", host = "127.0.0.1", path = "/", port = "8083", query = "a=1&b=2", scheme = "http"} --[[table: 0x14ad6a0]]
> cap
{"test/url_params"}
d9k commented 6 years ago

so I patched start-server.lua:

at the end of function(req,res,cap):

                    req.cmd_url = "/index.lua?"..conf.route_parameter.."="..vars[1].."/"..get

                    if req.parsed_url.query then
                      req.cmd_url = req.cmd_url .. '&' .. req.parsed_url.query
                    end
                else
                    req.cmd_url = "/index.lua"
                end

                return "reparse"
            end

new lines are:

                    if req.parsed_url.query then
                      req.cmd_url = req.cmd_url .. '&' .. req.parsed_url.query
                    end