File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,11 +22,24 @@ const url = require('url');
2222}
2323
2424{
25- assert . throws ( ( ) => {
26- url . pathToFileURL ( '\\\\exa mple\\share\\file.txt' , { windows : true } ) ;
27- } , {
28- code : 'ERR_INVALID_URL' ,
29- } ) ;
25+ const forbiddenHostnameChars = [
26+ '\\\\exa mple\\share\\file.txt' ,
27+ '\\\\host name\\share\\file.txt' , // space
28+ '\\\\host#name\\share\\file.txt' , // hash
29+ '\\\\host?name\\share\\file.txt' , // question mark
30+ '\\\\host@name\\share\\file.txt' , // at sign
31+ '\\\\host:name\\share\\file.txt' , // colon
32+ '\\\\host/name\\share\\file.txt' , // forward slash
33+ '\\\\host[name\\share\\file.txt' , // left bracket
34+ '\\\\host]name\\share\\file.txt' , // right bracket
35+ ] ;
36+ for ( const path of forbiddenHostnameChars ) {
37+ assert . throws ( ( ) => {
38+ url . pathToFileURL ( path , { windows : true } ) ;
39+ } , {
40+ code : 'ERR_INVALID_URL' ,
41+ } , `pathToFileURL('${ path } ') should throw ERR_INVALID_URL` ) ;
42+ }
3043}
3144
3245{
You can’t perform that action at this time.
0 commit comments