Skip to content

Commit 8eea04c

Browse files
authored
Create function.js
1 parent a8c1e48 commit 8eea04c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

function.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = function (context, data) {
2+
3+
var parsedForm = parseQuery(data.form);
4+
context.log(parsedForm);
5+
context.res = {
6+
body: parsedForm
7+
}
8+
context.done();
9+
};
10+
11+
function parseQuery(qstr) {
12+
var query = {};
13+
var a = qstr.replace('+', ' ').substr(0).split('&');
14+
for (var i = 0; i < a.length; i++) {
15+
var b = a[i].split('=');
16+
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
17+
}
18+
return query;
19+
}
20+

0 commit comments

Comments
 (0)