123456789101112131415161718192021222324252627282930313233 |
- function parseQuery(querystring) {
- let query = '';
- if (typeof querystring === 'string') {
- query = querystring;
- }
-
- return query
- .replace(/^\?/, '')
- .split('&')
- .reduce(function (acc, entry) {
- const pair = entry.split('=');
-
- if (pair[0]) {
- acc[pair[0]] = pair[1];
- }
- return acc;
- }, {});
- }
- module.exports = parseQuery;
|