Redirect to root on empty path 535/head
authorJoel Pedraza <github@saik0.net>
Fri, 30 Oct 2015 15:22:15 +0000 (11:22 -0400)
committerJoel Pedraza <joel@joelpedraza.com>
Tue, 3 Nov 2015 14:53:39 +0000 (09:53 -0500)
* Prevents an empty Location header
* Useful in environments where build_url() could return an empty string (such as http server rewrites requests to /cgi-bin/luci)

Signed-off-by: Joel Pedraza <github@saik0.net>
modules/luci-base/luasrc/http.lua

index a92d8af..4b35731 100644 (file)
@@ -208,6 +208,7 @@ function splice(fd, size)
 end
 
 function redirect(url)
+       if url == "" then url = "/" end
        status(302, "Found")
        header("Location", url)
        close()