File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ const common = require('../common');
44const fixtures = require ( '../common/fixtures' ) ;
55const assert = require ( 'assert' ) ;
66const fs = require ( 'fs' ) ;
7+ const tmpdir = require ( '../common/tmpdir' ) ;
8+ tmpdir . refresh ( ) ;
79
810const url = fixtures . fileURL ( 'a.js' ) ;
911
@@ -80,3 +82,25 @@ if (common.isWindows) {
8082 }
8183 ) ;
8284}
85+
86+ // Test that strings are interpreted as paths and not as URL
87+ // Can't use process.chdir in Workers
88+ // Please avoid testing fs.rmdir('file:') or using it as cleanup
89+ if ( common . isMainThread && ! common . isWindows ) {
90+ const oldCwd = process . cwd ( ) ;
91+ process . chdir ( tmpdir . path ) ;
92+
93+ for ( let slashCount = 0 ; slashCount < 9 ; slashCount ++ ) {
94+ const slashes = '/' . repeat ( slashCount ) ;
95+
96+ const dirname = `file:${ slashes } thisDirectoryWasMadeByFailingNodeJSTestSorry/subdir` ;
97+ fs . mkdirSync ( dirname , { recursive : true } ) ;
98+ fs . writeFileSync ( `${ dirname } /file` , `test failed with ${ slashCount } slashes` ) ;
99+
100+ const expected = fs . readFileSync ( tmpdir . resolve ( dirname , 'file' ) ) ;
101+ const actual = fs . readFileSync ( `${ dirname } /file` ) ;
102+ assert . deepStrictEqual ( actual , expected ) ;
103+ }
104+
105+ process . chdir ( oldCwd ) ;
106+ }
You can’t perform that action at this time.
0 commit comments