./bin/resty -e 'ngx.say(ngx.escape_uri([[{"name":"value","hello":"world"}]]))'
%7B%22name%22%3A%22value%22,%22hello%22%3A%22world%22%7D
local _M = {}function _M.escape (str) str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") return strendfunction _M.unescape (s) s = string.gsub(s, "+", " ") s = string.gsub(s, "%%(%x%x)", function (h) return string.char(tonumber(h, 16)) end) return sendreturn _M
./bin/resty -e 'local url = "" "url" ngx.say(url.escape([[{"name":"value","hello":"world"}]]))'
%7B%22name%22%3A%22value%22%2C%22hello%22%3A%22world%22%7D
Hello! On Thu, Mar 31, 2016 at 2:53 AM, Guanglin Lv wrote: > I need to encode some string using URL style %XX encoding. but ngxescape_uri > doest encode the comma character. > Patches welcome :) Regards, -agentzh