Fixed use of pattern special chars in lume.trim()

Using lua pattern special chars in the `chars` argument of lume.trim()
are now handled correctly and treated like any other character.
This commit is contained in:
rxi 2014-03-19 20:14:48 +00:00
parent d69f419f5a
commit ad64d7af05

View File

@ -288,7 +288,8 @@ end
function lume.trim(str, chars) function lume.trim(str, chars)
chars = chars or "%s" if not chars then return str:match("^[%s]*(.-)[%s]*$") end
chars = chars:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%1")
return str:match("^[" .. chars .. "]*(.-)[" .. chars .. "]*$") return str:match("^[" .. chars .. "]*(.-)[" .. chars .. "]*$")
end end