Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esm: shorten ERR_UNSUPPORTED_ESM_URL_SCHEME message #34836

Merged
merged 1 commit into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,8 @@ E('ERR_UNSUPPORTED_DIR_IMPORT', "Directory import '%s' is not supported " +
E('ERR_UNSUPPORTED_ESM_URL_SCHEME', (url) => {
let msg = 'Only file and data URLs are supported by the default ESM loader';
if (isWindows && url.protocol.length === 2) {
msg += '. Absolute Windows paths without prefix are not valid URLs, ' +
"consider using 'file://' prefix";
msg +=
'. On Windows, absolute paths must be valid file:// URLs';
}
msg += `. Received protocol '${url.protocol}'`;
return msg;
Expand Down
4 changes: 2 additions & 2 deletions test/es-module/test-esm-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function expectFsNamespace(result) {
if (common.isWindows) {
const msg =
'Only file and data URLs are supported by the default ESM loader. ' +
'Absolute Windows paths without prefix are not valid URLs, ' +
"consider using 'file://' prefix. Received protocol 'c:'";
'On Windows, absolute paths must be valid file:// URLs. ' +
"Received protocol 'c:'";
Trott marked this conversation as resolved.
Show resolved Hide resolved
expectModuleError(import('C:\\example\\foo.mjs'),
'ERR_UNSUPPORTED_ESM_URL_SCHEME',
msg);
Expand Down