* Fixed ffluci.util.trim, ffluci.util.split
[project/luci.git] / core / src / ffluci / util.lua
index 9cb1e1420c644f5ae38b5159bbab027728049bb0..3ff7bc2033f5e7a970e4ab6fccc47e29e6dc3b3f 100644 (file)
@@ -153,6 +153,10 @@ function split(str, pat, max, regex)
        local t = {}
        local c = 1
        
+       if #str == 0 then
+               return {""}
+       end
+       
        if #pat == 0 then
                return nil
        end
@@ -172,8 +176,9 @@ function split(str, pat, max, regex)
 end
 
 -- Removes whitespace from beginning and end of a string
-function trim (string)
-       return string:gsub("^%s*(.-)%s*$", "%1")
+function trim(string)
+       local s = string:gsub("^%s*(.-)%s*$", "%1")
+       return s
 end
 
 -- Updates given table with new values