Skip to content

Instantly share code, notes, and snippets.

@danielscholl
Created June 10, 2017 22:39
Show Gist options
  • Save danielscholl/09df2baf55750b276b22f36be4e5ed1d to your computer and use it in GitHub Desktop.
Save danielscholl/09df2baf55750b276b22f36be4e5ed1d to your computer and use it in GitHub Desktop.
URL Function Parser
module.exports = function (context, data) {
var parsedForm = parseQuery(data.form);
context.log(parsedForm);
context.res = {
body: parsedForm
}
context.done();
};
function parseQuery(qstr) {
var query = {};
var a = qstr.replace('+', ' ').substr(0).split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
return query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment