From 91596493954110f2a4171d9fb82ab31cba1d71b0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 18 Aug 2020 18:06:35 -0700 Subject: [PATCH] esm: shorten ERR_UNSUPPORTED_ESM_URL_SCHEME message I know it just got modified to include new information, but this shortens the message a bit without (I hope) losing clarity or meaning. PR-URL: https://github.com/nodejs/node/pull/34836 Backport-PR-URL: https://github.com/nodejs/node/pull/35385 Reviewed-By: Guy Bedford Reviewed-By: Denys Otrishko --- lib/internal/errors.js | 4 ++-- test/es-module/test-esm-dynamic-import.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index f2c49ec0e545ea..f6f1d131815b4d 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1404,8 +1404,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; diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 24d13d7fb8662d..4e87866b2bad3b 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -62,8 +62,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:'"; expectModuleError(import('C:\\example\\foo.mjs'), 'ERR_UNSUPPORTED_ESM_URL_SCHEME', msg);