Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser/main/lib/dataApi/copyFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function copyFile (srcPath, dstPath) {
const dstFolder = path.dirname(dstPath)
if (!fs.existsSync(dstFolder)) fs.mkdirSync(dstFolder)

const input = fs.createReadStream(srcPath)
const input = fs.createReadStream(decodeURI(srcPath))
const output = fs.createWriteStream(dstPath)

output.on('error', reject)
Expand Down
35 changes: 35 additions & 0 deletions tests/dataApi/copyFile-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const test = require('ava')
const copyFile = require('browser/main/lib/dataApi/copyFile')

const path = require('path')
const fs = require('fs')

const testFile = 'test.txt'
const srcFolder = path.join(__dirname, '🤔')
const srcPath = path.join(srcFolder, testFile)
const dstFolder = path.join(__dirname, '😇')
const dstPath = path.join(dstFolder, testFile)

test.before((t) => {
if (!fs.existsSync(srcFolder)) fs.mkdirSync(srcFolder)

fs.writeFileSync(srcPath, 'test')
})

test('`copyFile` should handle encoded URI on src path', (t) => {
return copyFile(encodeURI(srcPath), dstPath)
.then(() => {
t.true(true)
})
.catch(() => {
t.true(false)
})
})

test.after((t) => {
fs.unlinkSync(srcPath)
fs.unlinkSync(dstPath)
fs.rmdirSync(srcFolder)
fs.rmdirSync(dstFolder)
})