@@ -28,12 +28,10 @@ fs.readFile(url, common.mustCall((err, data) => {
28
28
29
29
// Check that using a non file:// URL reports an error
30
30
const httpUrl = new URL ( 'http://example.org' ) ;
31
- fs . readFile ( httpUrl , common . mustCall ( ( err ) => {
32
- common . expectsError ( {
33
- code : 'ERR_INVALID_URL_SCHEME' ,
34
- type : TypeError ,
35
- message : 'The URL must be of scheme file'
36
- } ) ( err ) ;
31
+ fs . readFile ( httpUrl , common . expectsError ( {
32
+ code : 'ERR_INVALID_URL_SCHEME' ,
33
+ type : TypeError ,
34
+ message : 'The URL must be of scheme file'
37
35
} ) ) ;
38
36
39
37
// pct-encoded characters in the path will be decoded and checked
@@ -46,31 +44,25 @@ fs.readFile(new URL('file:///c:/tmp/%00test'), common.mustCall((err) => {
46
44
if ( common . isWindows ) {
47
45
// encoded back and forward slashes are not permitted on windows
48
46
[ '%2f' , '%2F' , '%5c' , '%5C' ] . forEach ( ( i ) => {
49
- fs . readFile ( new URL ( `file:///c:/tmp/${ i } ` ) , common . mustCall ( ( err ) => {
50
- common . expectsError ( {
51
- code : 'ERR_INVALID_FILE_URL_PATH' ,
52
- type : TypeError ,
53
- message : 'File URL path must not include encoded \\ or / characters'
54
- } ) ( err ) ;
47
+ fs . readFile ( new URL ( `file:///c:/tmp/${ i } ` ) , common . expectsError ( {
48
+ code : 'ERR_INVALID_FILE_URL_PATH' ,
49
+ type : TypeError ,
50
+ message : 'File URL path must not include encoded \\ or / characters'
55
51
} ) ) ;
56
52
} ) ;
57
53
} else {
58
54
// encoded forward slashes are not permitted on other platforms
59
55
[ '%2f' , '%2F' ] . forEach ( ( i ) => {
60
- fs . readFile ( new URL ( `file:///c:/tmp/${ i } ` ) , common . mustCall ( ( err ) => {
61
- common . expectsError ( {
62
- code : 'ERR_INVALID_FILE_URL_PATH' ,
63
- type : TypeError ,
64
- message : 'File URL path must not include encoded / characters'
65
- } ) ( err ) ;
56
+ fs . readFile ( new URL ( `file:///c:/tmp/${ i } ` ) , common . expectsError ( {
57
+ code : 'ERR_INVALID_FILE_URL_PATH' ,
58
+ type : TypeError ,
59
+ message : 'File URL path must not include encoded / characters'
66
60
} ) ) ;
67
61
} ) ;
68
62
69
- fs . readFile ( new URL ( 'file://hostname/a/b/c' ) , common . mustCall ( ( err ) => {
70
- common . expectsError ( {
71
- code : 'ERR_INVALID_FILE_URL_HOST' ,
72
- type : TypeError ,
73
- message : `File URL host must be "localhost" or empty on ${ os . platform ( ) } `
74
- } ) ( err ) ;
63
+ fs . readFile ( new URL ( 'file://hostname/a/b/c' ) , common . expectsError ( {
64
+ code : 'ERR_INVALID_FILE_URL_HOST' ,
65
+ type : TypeError ,
66
+ message : `File URL host must be "localhost" or empty on ${ os . platform ( ) } `
75
67
} ) ) ;
76
68
}
0 commit comments