Skip to content

Commit fe429e9

Browse files
committed
Update to use buffer in encode/decode note id
Signed-off-by: Max Wu <jackymaxj@gmail.com>
1 parent 44298ba commit fe429e9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/models/note.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ module.exports = function (sequelize, DataTypes) {
117117
},
118118
encodeNoteId: function (id) {
119119
// remove dashes in UUID and encode in url-safe base64
120-
return base64url.encode(id.replace(/-/g, ''))
120+
let str = id.replace(/-/g, '')
121+
let hexStr = Buffer.from(str, 'hex')
122+
return base64url.encode(hexStr)
121123
},
122124
decodeNoteId: function (encodedId) {
123125
// decode from url-safe base64
124-
let id = base64url.decode(encodedId)
126+
let id = base64url.toBuffer(encodedId).toString('hex')
125127
// add dashes between the UUID string parts
126128
let idParts = []
127129
idParts.push(id.substr(0, 8))

0 commit comments

Comments
 (0)