Skip to content

Commit f5ed39f

Browse files
committed
fixup! module: improve error message for invalid data URL
1 parent a609fcc commit f5ed39f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/internal/modules/esm/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Loader {
116116
);
117117
throw new ERR_INVALID_MODULE_SPECIFIER(
118118
url,
119-
dataUrl ? `unsupported MIME "${dataUrl[1]}"` : '');
119+
dataUrl ? `has an unsupported MIME type "${dataUrl[1]}"` : '');
120120
}
121121
if (typeof format !== 'string') {
122122
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(

test/es-module/test-esm-invalid-data-urls.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ const assert = require('assert');
66
await assert.rejects(import('data:text/plain,export default0'), {
77
code: 'ERR_INVALID_MODULE_SPECIFIER',
88
message:
9-
'Invalid module "data:text/plain,export default0" unsupported MIME ' +
10-
'"text/plain"',
9+
'Invalid module "data:text/plain,export default0" has an unsupported ' +
10+
'MIME type "text/plain"',
1111
});
1212
await assert.rejects(import('data:text/plain;base64,'), {
1313
code: 'ERR_INVALID_MODULE_SPECIFIER',
14-
message: 'Invalid module "data:text/plain;base64," unsupported MIME ' +
15-
'"text/plain"',
14+
message:
15+
'Invalid module "data:text/plain;base64," has an unsupported ' +
16+
'MIME type "text/plain"',
1617
});
1718
await assert.rejects(import('data:application/json,[]'), {
1819
code: 'ERR_INVALID_MODULE_SPECIFIER',
19-
message: 'Invalid module "data:application/json,[]" unsupported MIME ' +
20-
'"application/json"',
20+
message:
21+
'Invalid module "data:application/json,[]" has an unsupported ' +
22+
'MIME type "application/json"',
2123
});
2224
})().then(common.mustCall());

0 commit comments

Comments
 (0)