33// external modules
44var fs = require ( 'fs' )
55var markdownpdf = require ( 'markdown-pdf' )
6- var LZString = require ( 'lz-string' )
76var shortId = require ( 'shortid' )
87var querystring = require ( 'querystring' )
98var request = require ( 'request' )
@@ -124,7 +123,7 @@ function newNote (req, res, next) {
124123 alias : req . alias ? req . alias : null ,
125124 content : req . body ? req . body : ''
126125 } ) . then ( function ( note ) {
127- return res . redirect ( config . serverurl + '/' + LZString . compressToBase64 ( note . id ) )
126+ return res . redirect ( config . serverurl + '/' + models . Note . encodeNoteId ( note . id ) )
128127 } ) . catch ( function ( err ) {
129128 logger . error ( err )
130129 return response . errorInternalError ( res )
@@ -179,7 +178,7 @@ function showNote (req, res, next) {
179178 findNote ( req , res , function ( note ) {
180179 // force to use note id
181180 var noteId = req . params . noteId
182- var id = LZString . compressToBase64 ( note . id )
181+ var id = models . Note . encodeNoteId ( note . id )
183182 if ( ( note . alias && noteId !== note . alias ) || ( ! note . alias && noteId !== id ) ) { return res . redirect ( config . serverurl + '/' + ( note . alias || id ) ) }
184183 return responseHackMD ( res , note )
185184 } )
@@ -321,7 +320,7 @@ function actionPDF (req, res, note) {
321320function actionGist ( req , res , note ) {
322321 var data = {
323322 client_id : config . github . clientID ,
324- redirect_uri : config . serverurl + '/auth/github/callback/' + LZString . compressToBase64 ( note . id ) + '/gist' ,
323+ redirect_uri : config . serverurl + '/auth/github/callback/' + models . Note . encodeNoteId ( note . id ) + '/gist' ,
325324 scope : 'gist' ,
326325 state : shortId . generate ( )
327326 }
@@ -418,7 +417,7 @@ function publishNoteActions (req, res, next) {
418417 var action = req . params . action
419418 switch ( action ) {
420419 case 'edit' :
421- res . redirect ( config . serverurl + '/' + ( note . alias ? note . alias : LZString . compressToBase64 ( note . id ) ) )
420+ res . redirect ( config . serverurl + '/' + ( note . alias ? note . alias : models . Note . encodeNoteId ( note . id ) ) )
422421 break
423422 default :
424423 res . redirect ( config . serverurl + '/s/' + note . shortid )
@@ -432,7 +431,7 @@ function publishSlideActions (req, res, next) {
432431 var action = req . params . action
433432 switch ( action ) {
434433 case 'edit' :
435- res . redirect ( config . serverurl + '/' + ( note . alias ? note . alias : LZString . compressToBase64 ( note . id ) ) )
434+ res . redirect ( config . serverurl + '/' + ( note . alias ? note . alias : models . Note . encodeNoteId ( note . id ) ) )
436435 break
437436 default :
438437 res . redirect ( config . serverurl + '/p/' + note . shortid )
0 commit comments