Created
June 10, 2017 22:39
-
-
Save danielscholl/09df2baf55750b276b22f36be4e5ed1d to your computer and use it in GitHub Desktop.
URL Function Parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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