1 | var staticDecodeURIComponent = require('./staticDecodeURIComponent')
|
2 |
|
3 | var arrayEach = require('./arrayEach')
|
4 |
|
5 | var isString = require('./isString')
|
6 |
|
7 | /**
|
8 | * 反序列化查询参数
|
9 | * @param {String} query 字符串
|
10 | */
|
11 | function unserialize (str) {
|
12 | var items
|
13 | var result = {}
|
14 | if (str && isString(str)) {
|
15 | arrayEach(str.split('&'), function (param) {
|
16 | items = param.split('=')
|
17 | result[staticDecodeURIComponent(items[0])] = staticDecodeURIComponent(items[1] || '')
|
18 | })
|
19 | }
|
20 | return result
|
21 | }
|
22 |
|
23 | module.exports = unserialize
|