Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/middleware/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,12 @@ func (mw *FaygoJWTMiddleware) jwtFromHeader(c *faygo.Context, key string) (strin
return "", ErrEmptyAuthHeader
}

// ios某些版本,有空格的话,会报SyntaxError DOM Exception 12,前端调用时可以改用Bearer/xxxxxxxxx格式,兼容之前的Bearer xxxxxxxxx格式
parts := strings.SplitN(authHeader, " ", 2)
if len(parts) == 2 && parts[0] == mw.TokenHeadName {
return parts[1], nil
}
parts = strings.SplitN(authHeader, "/", 2)
if !(len(parts) == 2 && parts[0] == mw.TokenHeadName) {
return "", ErrInvalidAuthHeader
}
Expand Down