diff options
author | Max Wu | 2018-02-27 20:57:31 +0800 |
---|---|---|
committer | Max Wu | 2018-02-27 20:57:31 +0800 |
commit | fe429e9ac17b73638835b2ec1c5033043c5f9942 (patch) | |
tree | 46444c99aac74da523902ad72c8a5069d64b0126 | |
parent | 44298baa935916c61d8402122ed5801b1d973acd (diff) |
Update to use buffer in encode/decode note id
Signed-off-by: Max Wu <jackymaxj@gmail.com>
-rw-r--r-- | lib/models/note.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index e199a3db..119d72c3 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -117,11 +117,13 @@ module.exports = function (sequelize, DataTypes) { }, encodeNoteId: function (id) { // remove dashes in UUID and encode in url-safe base64 - return base64url.encode(id.replace(/-/g, '')) + let str = id.replace(/-/g, '') + let hexStr = Buffer.from(str, 'hex') + return base64url.encode(hexStr) }, decodeNoteId: function (encodedId) { // decode from url-safe base64 - let id = base64url.decode(encodedId) + let id = base64url.toBuffer(encodedId).toString('hex') // add dashes between the UUID string parts let idParts = [] idParts.push(id.substr(0, 8)) |