Skip to content

Commit

Permalink
fix: handle optional leading "@" in script_path()
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
open-dynaMIX committed Dec 1, 2020
1 parent 40c109f commit 2410f91
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions webui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ local url = require("socket.url")
local MSG_PREFIX = "[webui] "
local VERSION = "2.0.0"

function string.starts(String, Start)
return string.sub(String,1,string.len(Start))==Start
end

local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
local str = debug.getinfo(2, "S").source
if string.starts(str,"@") then
str = str:sub(2)
end
return str:match("(.*/)")
end

Expand Down Expand Up @@ -431,10 +438,6 @@ local function header(code, content_type, content_length)
end
end

function string.starts(String, Start)
return string.sub(String,1,string.len(Start))==Start
end

local function concatkeys(tab, sep)
local inter = {}
for key,_ in pairs(tab) do
Expand Down

0 comments on commit 2410f91

Please sign in to comment.