Skip to content

Commit 2410f91

Browse files
committed
fix: handle optional leading "@" in script_path()
Closes #71
1 parent 40c109f commit 2410f91

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

webui.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ local url = require("socket.url")
88
local MSG_PREFIX = "[webui] "
99
local VERSION = "2.0.0"
1010

11+
function string.starts(String, Start)
12+
return string.sub(String,1,string.len(Start))==Start
13+
end
14+
1115
local function script_path()
12-
local str = debug.getinfo(2, "S").source:sub(2)
16+
local str = debug.getinfo(2, "S").source
17+
if string.starts(str,"@") then
18+
str = str:sub(2)
19+
end
1320
return str:match("(.*/)")
1421
end
1522

@@ -431,10 +438,6 @@ local function header(code, content_type, content_length)
431438
end
432439
end
433440

434-
function string.starts(String, Start)
435-
return string.sub(String,1,string.len(Start))==Start
436-
end
437-
438441
local function concatkeys(tab, sep)
439442
local inter = {}
440443
for key,_ in pairs(tab) do

0 commit comments

Comments
 (0)