Use mg.script_name to retrieve the scriptname

This value is independent from webhome or prefix

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign
2025-05-08 23:06:06 -03:00
parent 796d5922a6
commit 66f7e1d081

View File

@@ -14,7 +14,8 @@ webhome = pihole.webhome()
theme = pihole.webtheme()
-- Get name of script by matching whatever is after the last "/" in the URI
scriptname = mg.request_info.request_uri:match(webhome.."(.*)$")
scriptname = mg.script_name:match(".*/(.*).lp$"):gsub("-", "/")
-- Fall back to "index.lp" if no match is found (e.g. when accessing the root)
if scriptname == nil or string.len(scriptname) == 0 then scriptname = "index.lp" end