mirror of
https://gitlab.com/upRootNutrition/obsidian.git
synced 2025-06-15 15:15:11 -05:00
18 lines
No EOL
455 B
Lua
Executable file
18 lines
No EOL
455 B
Lua
Executable file
local function encode (str)
|
|
str = string.gsub (str, "([^0-9a-zA-Z !'()*._~-])", -- locale independent
|
|
function (c) return string.format ("%%%02X", string.byte(c)) end)
|
|
str = string.gsub (str, " ", "%%20")
|
|
return str
|
|
end
|
|
|
|
|
|
local function decode (str)
|
|
str = string.gsub (str, "%%20", " ")
|
|
str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
|
|
return str
|
|
end
|
|
|
|
return {
|
|
encode = encode,
|
|
decode = decode
|
|
} |