File tree Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,11 @@ const common = require('../../common');
55const assert = require ( 'assert' ) ;
66const fs = require ( 'fs' ) ;
77const path = require ( 'path' ) ;
8+ const { pathToFileURL } = require ( 'url' ) ;
89
910const blockedFile = process . env . BLOCKEDFILE ;
1011const bufferBlockedFile = Buffer . from ( process . env . BLOCKEDFILE ) ;
11- const blockedFileURL = new URL ( 'file://' + process . env . BLOCKEDFILE ) ;
12+ const blockedFileURL = pathToFileURL ( process . env . BLOCKEDFILE ) ;
1213const blockedFolder = process . env . BLOCKEDFOLDER ;
1314const allowedFolder = process . env . ALLOWEDFOLDER ;
1415const regularFile = __filename ;
Original file line number Diff line number Diff line change 22const common = require ( '../common' ) ;
33const assert = require ( 'assert' ) ;
44const dc = require ( 'diagnostics_channel' ) ;
5+ const { pathToFileURL } = require ( 'url' ) ;
56
67const trace = dc . tracingChannel ( 'module.import' ) ;
78const events = [ ] ;
@@ -30,10 +31,7 @@ trace.subscribe({
3031import ( 'does-not-exist' ) . then (
3132 common . mustNotCall ( ) ,
3233 common . mustCall ( ( error ) => {
33- let expectedParentURL = module . filename . replaceAll ( '\\' , '/' ) ;
34- expectedParentURL = common . isWindows ?
35- `file:///${ expectedParentURL } ` :
36- `file://${ expectedParentURL } ` ;
34+ const expectedParentURL = pathToFileURL ( module . filename ) . href ;
3735 // Verify order and contents of each event
3836 assert . deepStrictEqual ( events , [
3937 {
Original file line number Diff line number Diff line change 22const common = require ( '../common' ) ;
33const assert = require ( 'assert' ) ;
44const dc = require ( 'diagnostics_channel' ) ;
5+ const { pathToFileURL } = require ( 'url' ) ;
56
67const trace = dc . tracingChannel ( 'module.import' ) ;
78const events = [ ] ;
@@ -29,10 +30,7 @@ trace.subscribe({
2930
3031import ( 'http' ) . then (
3132 common . mustCall ( ( result ) => {
32- let expectedParentURL = module . filename . replaceAll ( '\\' , '/' ) ;
33- expectedParentURL = common . isWindows ?
34- `file:///${ expectedParentURL } ` :
35- `file://${ expectedParentURL } ` ;
33+ const expectedParentURL = pathToFileURL ( module . filename ) . href ;
3634 // Verify order and contents of each event
3735 assert . deepStrictEqual ( events , [
3836 {
You can’t perform that action at this time.
0 commit comments