File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function copyFile (srcPath, dstPath) {
1616 const dstFolder = path . dirname ( dstPath )
1717 if ( ! fs . existsSync ( dstFolder ) ) fs . mkdirSync ( dstFolder )
1818
19- const input = fs . createReadStream ( srcPath )
19+ const input = fs . createReadStream ( decodeURI ( srcPath ) )
2020 const output = fs . createWriteStream ( dstPath )
2121
2222 output . on ( 'error' , reject )
Original file line number Diff line number Diff line change 1+ const test = require ( 'ava' )
2+ const copyFile = require ( 'browser/main/lib/dataApi/copyFile' )
3+
4+ const path = require ( 'path' )
5+ const fs = require ( 'fs' )
6+
7+ const testFile = 'test.txt'
8+ const srcFolder = path . join ( __dirname , '🤔' )
9+ const srcPath = path . join ( srcFolder , testFile )
10+ const dstFolder = path . join ( __dirname , '😇' )
11+ const dstPath = path . join ( dstFolder , testFile )
12+
13+ test . before ( ( t ) => {
14+ if ( ! fs . existsSync ( srcFolder ) ) fs . mkdirSync ( srcFolder )
15+
16+ fs . writeFileSync ( srcPath , 'test' )
17+ } )
18+
19+ test ( '`copyFile` should handle encoded URI on src path' , ( t ) => {
20+ return copyFile ( encodeURI ( srcPath ) , dstPath )
21+ . then ( ( ) => {
22+ t . true ( true )
23+ } )
24+ . catch ( ( ) => {
25+ t . true ( false )
26+ } )
27+ } )
28+
29+ test . after ( ( t ) => {
30+ fs . unlinkSync ( srcPath )
31+ fs . unlinkSync ( dstPath )
32+ fs . rmdirSync ( srcFolder )
33+ fs . rmdirSync ( dstFolder )
34+ } )
35+
You can’t perform that action at this time.
0 commit comments