File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function copyFile (srcPath, dstPath) {
16
16
const dstFolder = path . dirname ( dstPath )
17
17
if ( ! fs . existsSync ( dstFolder ) ) fs . mkdirSync ( dstFolder )
18
18
19
- const input = fs . createReadStream ( srcPath )
19
+ const input = fs . createReadStream ( decodeURI ( srcPath ) )
20
20
const output = fs . createWriteStream ( dstPath )
21
21
22
22
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