jbe/bsw@0: --[[-- jbe/bsw@0: url_encoded_string = -- URL-encoded string jbe/bsw@0: encode.url_part( jbe/bsw@0: obj -- any native datatype or atom jbe/bsw@0: ) jbe/bsw@0: jbe/bsw@0: This function encodes any native datatype or atom in a way that it can be placed inside an URL. It is first dumped with atom.dump(...) and then url-encoded. jbe/bsw@0: jbe/bsw@0: --]]-- jbe/bsw@0: jbe/bsw@0: function encode.url_part(obj) jbe/bsw@0: return ( jbe/bsw@0: string.gsub( jbe/bsw@0: atom.dump(obj), jbe/bsw@0: "[^0-9A-Za-z_%.~-]", jbe/bsw@0: function (char) jbe/bsw@0: return string.format("%%%02x", string.byte(char)) jbe/bsw@0: end jbe/bsw@0: ) jbe/bsw@0: ) jbe/bsw@0: end