| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,10 +5,11 @@ const common = require('../../common'); | |||
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const fs = require('fs'); | |
| 7 | 7 | const path = require('path'); | |
| 8 | + const { pathToFileURL } = require('url'); | ||
| 8 | 9 | ||
| 9 | 10 | const blockedFile = process.env.BLOCKEDFILE; | |
| 10 | 11 | const bufferBlockedFile = Buffer.from(process.env.BLOCKEDFILE); | |
| 11 | - const blockedFileURL = new URL('file://' + process.env.BLOCKEDFILE); | ||
| 12 | + const blockedFileURL = pathToFileURL(process.env.BLOCKEDFILE); | ||
| 12 | 13 | const blockedFolder = process.env.BLOCKEDFOLDER; | |
| 13 | 14 | const allowedFolder = process.env.ALLOWEDFOLDER; | |
| 14 | 15 | const regularFile = __filename; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const dc = require('diagnostics_channel'); | |
| 5 | + const { pathToFileURL } = require('url'); | ||
| 5 | 6 | ||
| 6 | 7 | const trace = dc.tracingChannel('module.import'); | |
| 7 | 8 | const events = []; | |
@@ -30,10 +31,7 @@ trace.subscribe({ | |||
| 30 | 31 | import('does-not-exist').then( | |
| 31 | 32 | common.mustNotCall(), | |
| 32 | 33 | 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; | ||
| 37 | 35 | // Verify order and contents of each event | |
| 38 | 36 | assert.deepStrictEqual(events, [ | |
| 39 | 37 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const dc = require('diagnostics_channel'); | |
| 5 | + const { pathToFileURL } = require('url'); | ||
| 5 | 6 | ||
| 6 | 7 | const trace = dc.tracingChannel('module.import'); | |
| 7 | 8 | const events = []; | |
@@ -29,10 +30,7 @@ trace.subscribe({ | |||
| 29 | 30 | ||
| 30 | 31 | import('http').then( | |
| 31 | 32 | 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; | ||
| 36 | 34 | // Verify order and contents of each event | |
| 37 | 35 | assert.deepStrictEqual(events, [ | |
| 38 | 36 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments