Permalink
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
Cannot retrieve contributors at this time.
Cannot retrieve contributors at this time
| var reg = /([^?=&]+)(=([^&]*))?/g | |
| var assert = require('assert') | |
| module.exports = qs | |
| function qs (url) { | |
| assert.equal(typeof url, 'string', 'nanoquery: url should be type string') | |
| var obj = {} | |
| url.replace(/^.*\?/, '').replace(reg, function (a0, a1, a2, a3) { | |
| var value = decodeURIComponent(a3) | |
| var key = decodeURIComponent(a1) | |
| if (obj.hasOwnProperty(key)) { | |
| if (Array.isArray(obj[key])) obj[key].push(value) | |
| else obj[key] = [obj[key], value] | |
| } else { | |
| obj[key] = value | |
| } | |
| }) | |
| return obj | |
| } |