auth0 / express-jwt

connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the returned `err.name` contains spaces

ikexing-cn opened this issue · comments

Description

the returned err.name contains spaces.

Reproduction

app.use(expressjwt({
    secret: SECRET,
    algorithms: ['HS256']
}).unless({ path: unlesses }))

app.use((err, req, res, next) => {
    if (err.name. === 'TokenExpiredError') {
        console.log(1)
    } else {
        console.log(2)
    }
})

if it is the above code, the log is always 2.
but once you change it to err.name.trim(), everything works fine...

Environment

Please provide the following:

  • **Version of this library used: 7.7.2
  • **Version of the platform or framework used, if applicable: express
  • **Other relevant versions (language, server software, OS, browser): javascript / nodejs