From 0a8bc0b30644c514d822fb32a184318f7353a285 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 21:59:58 +1100 Subject: Add lua.to_uristring --- src/defs.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/defs.js') diff --git a/src/defs.js b/src/defs.js index 315364a..3ebb747 100644 --- a/src/defs.js +++ b/src/defs.js @@ -188,6 +188,25 @@ const to_jsstring = function(value, from, to) { return str; }; +const uri_allowed = {}; /* bytes allowed unescaped in a uri */ +for (let c of ";,/?:@&=+$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,-_.!~*'()#") { + uri_allowed[c.charCodeAt(0)] = true; +} + +/* utility function to convert a lua string to a js string with uri escaping */ +const to_uristring = function(a) { + let s = ""; + for (let i=0; i