Merge pull request #1680 from hackmdio/bugfix/fix-export-user-data-filename-zero

Avoid append zero suffix on exporting user data
This commit is contained in:
Raccoon 2021-05-13 12:56:04 +08:00 committed by GitHub
commit 3af5408d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -91,8 +91,11 @@ exports.exportMyData = (req, res) => {
let filename let filename
let suffix = 0 let suffix = 0
do { do {
const separator = suffix === 0 ? '' : '-' if (suffix === 0) {
filename = basename + separator + suffix + '.md' filename = basename + '.md'
} else {
filename = basename + '-' + suffix + '.md'
}
suffix++ suffix++
} while (filenames[filename]) } while (filenames[filename])
filenames[filename] = true filenames[filename] = true