1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-29 09:31:50 +00:00

Merge pull request #1698 from nlopin/fix_export_folder

Fix filenames with forbidden symbols during export #1613
This commit is contained in:
Junyoung Choi (Sai)
2018-03-19 23:23:47 +09:00
committed by GitHub
4 changed files with 29 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import { findStorage } from 'browser/lib/findStorage'
import resolveStorageData from './resolveStorageData'
import resolveStorageNotes from './resolveStorageNotes'
import filenamify from 'filenamify'
import * as path from 'path'
import * as fs from 'fs'
@@ -45,7 +46,7 @@ function exportFolder (storageKey, folderKey, fileType, exportDir) {
notes
.filter(note => note.folder === folderKey && note.isTrashed === false && note.type === 'MARKDOWN_NOTE')
.forEach(snippet => {
const notePath = path.join(exportDir, `${snippet.title}.${fileType}`)
const notePath = path.join(exportDir, `${filenamify(snippet.title, {replacement: '_'})}.${fileType}`)
fs.writeFileSync(notePath, snippet.content)
})

View File

@@ -1,5 +1,6 @@
import copyFile from 'browser/main/lib/dataApi/copyFile'
import {findStorage} from 'browser/lib/findStorage'
import filenamify from 'filenamify'
const fs = require('fs')
const path = require('path')
@@ -28,6 +29,7 @@ function exportNote (storageKey, noteContent, targetPath, outputFormatter) {
}
let exportedData = noteContent.replace(LOCAL_STORED_REGEX, (match, dstFilename, srcFilename) => {
dstFilename = filenamify(dstFilename, {replacement: '_'})
if (!path.extname(dstFilename)) {
dstFilename += path.extname(srcFilename)
}