Merge branch 'master' into DepauMD

This commit is contained in:
Davide Depau 2018-11-29 03:00:13 +01:00
commit 84dce80bc9
3 changed files with 15 additions and 13 deletions

View file

@ -100,7 +100,7 @@ oauth2Auth.get('/auth/oauth2', function (req, res, next) {
// github auth callback // github auth callback
oauth2Auth.get('/auth/oauth2/callback', oauth2Auth.get('/auth/oauth2/callback',
passport.authenticate('oauth2', { passport.authenticate('oauth2', {
successReturnToOrRedirect: config.serverurl + '/', successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverurl + '/' failureRedirect: config.serverURL + '/'
}) })
) )

View file

@ -55,7 +55,7 @@ openIDAuth.post('/auth/openid', urlencodedParser, function (req, res, next) {
// openID auth callback // openID auth callback
openIDAuth.get('/auth/openid/callback', openIDAuth.get('/auth/openid/callback',
passport.authenticate('openid', { passport.authenticate('openid', {
successReturnToOrRedirect: config.serverurl + '/', successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverurl + '/' failureRedirect: config.serverURL + '/'
}) })
) )

View file

@ -90,18 +90,20 @@ UserRouter.get('/me/export', function (req, res) {
ownerId: user.id ownerId: user.id
} }
}).then(function (notes) { }).then(function (notes) {
let list = [] let filenames = {}
async.each(notes, function (note, callback) { async.each(notes, function (note, callback) {
let title let basename = note.title.replace(/\//g, '-') // Prevent subdirectories
let extension = '' let filename
let suffix = ''
do { do {
title = note.title + extension let seperator = typeof suffix === 'number' ? '-' : ''
extension++ filename = basename + seperator + suffix + '.md'
} while (list.indexOf(title) !== -1) suffix++
} while (filenames[filename])
filenames[filename] = true
list.push(title) logger.debug('Write: ' + filename)
logger.debug('Write: ' + title + '.md') archive.append(Buffer.from(note.content), { name: filename, date: note.lastchangeAt })
archive.append(Buffer.from(note.content), { name: title + '.md', date: note.lastchangeAt })
callback(null, null) callback(null, null)
}, function (err) { }, function (err) {
if (err) { if (err) {