This commit is contained in:
2026-04-03 11:33:51 +02:00
parent 64922e1ae3
commit 0ed904319d
57 changed files with 2935 additions and 1377 deletions
+1 -29
View File
@@ -24,34 +24,6 @@ end
---@return string
function trim(str) return str:match('^%s*(.-)%s*$') end
---@param str string
---@return string|nil
function url_encode(str)
if str then
str = str:gsub('([^%w%-%.%_%~])', function(c)
return string.format('%%%02X', string.byte(c))
end)
end
return str
end
-- Escape special characters in url.
---@param str string
---@return string|nil
function url_decode(str)
local function hex_to_char(x)
return string.char(tonumber(x, 16))
end
if str ~= nil then
str = str:gsub('^file://', '')
str = str:gsub('%%(%x%x)', hex_to_char)
if str:find('://localhost:?') then
str = str:gsub('^.*/', '')
end
end
return str
end
-- Trim any `char` from the end of the string.
---@param str string
---@param char string
@@ -406,4 +378,4 @@ end
function CircularBuffer:clear()
itable_clear(self.data)
self.pos = 0
end
end