| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,7 +209,15 @@ function finalizeResolution(resolved, base, preserveSymlinks) { | |||
| 209 | 209 | resolved.pathname, 'must not include encoded "/" or "\\" characters', | |
| 210 | 210 | fileURLToPath(base)); | |
| 211 | 211 | ||
| 212 | - const path = fileURLToPath(resolved); | ||
| 212 | + let path; | ||
| 213 | + try { | ||
| 214 | + path = fileURLToPath(resolved); | ||
| 215 | + } catch (err) { | ||
| 216 | + const { setOwnProperty } = require('internal/util'); | ||
| 217 | + setOwnProperty(err, 'input', `${resolved}`); | ||
| 218 | + setOwnProperty(err, 'module', `${base}`); | ||
| 219 | + throw err; | ||
| 220 | + } | ||
| 213 | 221 | ||
| 214 | 222 | const stats = internalModuleStat(toNamespacedPath(StringPrototypeEndsWith(path, '/') ? | |
| 215 | 223 | StringPrototypeSlice(path, -1) : path)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,4 +49,18 @@ describe('default resolver', () => { | |||
| 49 | 49 | assert.strictEqual(stdout.trim(), 'index.byoe!'); | |
| 50 | 50 | assert.strictEqual(stderr, ''); | |
| 51 | 51 | }); | |
| 52 | + | ||
| 53 | + it('should identify the parent module of an invalid URL host in import specifier', async () => { | ||
| 54 | + if (process.platform === 'win32') return; | ||
| 55 | + | ||
| 56 | + const { code, stderr } = await spawnPromisified(execPath, [ | ||
| 57 | + '--no-warnings', | ||
| 58 | + fixtures.path('es-modules', 'invalid-posix-host.mjs'), | ||
| 59 | + ]); | ||
| 60 | + | ||
| 61 | + assert.match(stderr, /ERR_INVALID_FILE_URL_HOST/); | ||
| 62 | + assert.match(stderr, /file:\/\/hmm\.js/); | ||
| 63 | + assert.match(stderr, /invalid-posix-host\.mjs/); | ||
| 64 | + assert.strictEqual(code, 1); | ||
| 65 | + }); | ||
| 52 | 66 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + import "file://hmm.js"; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments