Skip to content

Commit c7657ae

Browse files
committed
Fix parseNoteId order to fix some edge case
that LZString note url could be parsed by base64url note url and thus return wrong note id Signed-off-by: Max Wu <jackymaxj@gmail.com>
1 parent 16cb842 commit c7657ae

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/models/note.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,20 @@ module.exports = function (sequelize, DataTypes) {
209209
return _callback(err, null)
210210
})
211211
},
212-
parseNoteIdByBase64Url: function (_callback) {
213-
// try to parse note id by base64url
212+
// parse note id by LZString is deprecated, here for compability
213+
parseNoteIdByLZString: function (_callback) {
214+
// try to parse note id by LZString Base64
214215
try {
215-
var id = Note.decodeNoteId(noteId)
216+
var id = LZString.decompressFromBase64(noteId)
216217
if (id && Note.checkNoteIdValid(id)) { return callback(null, id) } else { return _callback(null, null) }
217218
} catch (err) {
218219
return _callback(err, null)
219220
}
220221
},
221-
// parse note id by LZString is deprecated, here for compability
222-
parseNoteIdByLZString: function (_callback) {
223-
// try to parse note id by LZString Base64
222+
parseNoteIdByBase64Url: function (_callback) {
223+
// try to parse note id by base64url
224224
try {
225-
var id = LZString.decompressFromBase64(noteId)
225+
var id = Note.decodeNoteId(noteId)
226226
if (id && Note.checkNoteIdValid(id)) { return callback(null, id) } else { return _callback(null, null) }
227227
} catch (err) {
228228
return _callback(err, null)

0 commit comments

Comments
 (0)