1. 在调用模块前,若req.query.cookiereq.body.cookie是字符串,则先解码,再转为对象。

2. 删除在各模块中的转换。
3. 更新文档。
This commit is contained in:
Clark
2021-03-26 00:49:37 +08:00
parent 3fe3995f14
commit 39b32b4b61
5 changed files with 7 additions and 15 deletions

8
app.js
View File

@ -78,9 +78,11 @@ fs.readdirSync(path.join(__dirname, 'module'))
let question = require(path.join(__dirname, 'module', file))
app.use(route, (req, res) => {
if (typeof req.query.cookie === 'string') {
req.query.cookie = cookieToJson(req.query.cookie)
}
;[req.query, req.body].forEach((item) => {
if (typeof item.cookie === 'string') {
item.cookie = cookieToJson(decodeURIComponent(item.cookie))
}
})
let query = Object.assign(
{},
{ cookie: req.cookies },