Skip to content

Commit

Permalink
修复代码错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Sep 12, 2020
1 parent 4f7266e commit 3b15fe9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ app.use((req, res, next) => {

// cookie parser
app.use((req, res, next) => {
req.cookies = {}(req.headers.cookie || '')
.split(/\s*;\s*/)
.forEach((pair) => {
let crack = pair.indexOf('=')
if (crack < 1 || crack == pair.length - 1) return
req.cookies[
decodeURIComponent(pair.slice(0, crack)).trim()
] = decodeURIComponent(pair.slice(crack + 1)).trim()
})
req.cookies = {}
;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => {
let crack = pair.indexOf('=')
if (crack < 1 || crack == pair.length - 1) return
req.cookies[
decodeURIComponent(pair.slice(0, crack)).trim()
] = decodeURIComponent(pair.slice(crack + 1)).trim()
})
next()
})

Expand Down

0 comments on commit 3b15fe9

Please sign in to comment.