@@ -28,12 +28,10 @@ fs.readFile(url, common.mustCall((err, data) => {
2828
2929// Check that using a non file:// URL reports an error
3030const 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'
3735} ) ) ;
3836
3937// 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) => {
4644if ( common . isWindows ) {
4745 // encoded back and forward slashes are not permitted on windows
4846 [ '%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'
5551 } ) ) ;
5652 } ) ;
5753} else {
5854 // encoded forward slashes are not permitted on other platforms
5955 [ '%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'
6660 } ) ) ;
6761 } ) ;
6862
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 ( ) } `
7567 } ) ) ;
7668}
0 commit comments