summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-03-18 15:13:06 +0100
committerGitHub2018-03-18 15:13:06 +0100
commitf6df2deb8439dda4576ee70691c98c1ab53c965d (patch)
tree6a56c539e86058cf89a50636b451167fc3a75f83 /lib/response.js
parent6b30f662725b54d9c0ef3954fdb5a463da697cc2 (diff)
parent8bfe51940f2eff035394b7713cbbce5b9b446842 (diff)
Merge pull request #743 from hackmdio/fix-to-use-url-safe-base64
Fix to use url-safe base64 in note url
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/response.js b/lib/response.js
index 41e8c336..25b9fafc 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -3,7 +3,6 @@
// external modules
var fs = require('fs')
var markdownpdf = require('markdown-pdf')
-var LZString = require('lz-string')
var shortId = require('shortid')
var querystring = require('querystring')
var request = require('request')
@@ -124,7 +123,7 @@ function newNote (req, res, next) {
alias: req.alias ? req.alias : null,
content: req.body ? req.body : ''
}).then(function (note) {
- return res.redirect(config.serverurl + '/' + LZString.compressToBase64(note.id))
+ return res.redirect(config.serverurl + '/' + models.Note.encodeNoteId(note.id))
}).catch(function (err) {
logger.error(err)
return response.errorInternalError(res)
@@ -179,7 +178,7 @@ function showNote (req, res, next) {
findNote(req, res, function (note) {
// force to use note id
var noteId = req.params.noteId
- var id = LZString.compressToBase64(note.id)
+ var id = models.Note.encodeNoteId(note.id)
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) { return res.redirect(config.serverurl + '/' + (note.alias || id)) }
return responseHackMD(res, note)
})
@@ -321,7 +320,7 @@ function actionPDF (req, res, note) {
function actionGist (req, res, note) {
var data = {
client_id: config.github.clientID,
- redirect_uri: config.serverurl + '/auth/github/callback/' + LZString.compressToBase64(note.id) + '/gist',
+ redirect_uri: config.serverurl + '/auth/github/callback/' + models.Note.encodeNoteId(note.id) + '/gist',
scope: 'gist',
state: shortId.generate()
}
@@ -418,7 +417,7 @@ function publishNoteActions (req, res, next) {
var action = req.params.action
switch (action) {
case 'edit':
- res.redirect(config.serverurl + '/' + (note.alias ? note.alias : LZString.compressToBase64(note.id)))
+ res.redirect(config.serverurl + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)))
break
default:
res.redirect(config.serverurl + '/s/' + note.shortid)
@@ -432,7 +431,7 @@ function publishSlideActions (req, res, next) {
var action = req.params.action
switch (action) {
case 'edit':
- res.redirect(config.serverurl + '/' + (note.alias ? note.alias : LZString.compressToBase64(note.id)))
+ res.redirect(config.serverurl + '/' + (note.alias ? note.alias : models.Note.encodeNoteId(note.id)))
break
default:
res.redirect(config.serverurl + '/p/' + note.shortid)