Skip to content

Commit 1dc83f5

Browse files
committed
percent-encoded target test
1 parent 8fe68f7 commit 1dc83f5

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

doc/api/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,4 +2787,4 @@ such as `process.stdout.on('data')`.
27872787
[vm]: vm.html
27882788
[self-reference a package using its name]: esm.html#esm_self_referencing_a_package_using_its_name
27892789
[define a custom subpath]: esm.html#esm_subpath_exports
2790-
["imports" field]: esm.html#internal_package_imports
2790+
["imports" field]: esm.html#esm_internal_package_imports

lib/internal/modules/cjs/loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
574574
try {
575575
return fileURLToPath(resolved);
576576
} catch (err) {
577-
if (err.code === 'ERR_INVALID_FILE_URL_PATH' &&
578-
StringPrototypeIncludes(err.message, 'must not include encoded "/" characters')) {
577+
if (err.code === 'ERR_INVALID_FILE_URL_PATH' && StringPrototypeIncludes(
578+
err.message, 'must not include encoded "/" characters')) {
579579
throw new ERR_INVALID_MODULE_SPECIFIER(
580580
resolved.pathname, 'must not include encoded "/" characters',
581581
fileURLToPath(baseUrl));

test/es-module/test-esm-imports.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const { requireImport, importImport } = importer;
5858
['#', '#'],
5959
// Initial slash target must have a leading name
6060
['#/initialslash', '#/initialslash'],
61+
// Percent-encoded target paths
62+
['#percent', 'must not include encoded "/"'],
6163
]);
6264

6365
for (const [specifier, expected] of invalidImportSpecifiers) {
@@ -81,7 +83,6 @@ const { requireImport, importImport } = importer;
8183

8284
for (const specifier of undefinedImports) {
8385
loadFixture(specifier).catch(mustCall((err) => {
84-
console.log(err);
8586
strictEqual(err.code, 'ERR_PACKAGE_IMPORT_NOT_DEFINED');
8687
assertStartsWith(err.message, 'Package import ');
8788
assertIncludes(err.message, specifier);

test/fixtures/es-modules/pkgimports/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"#subpath/nullshadow/": [null],
2525
"#": "./test.js",
2626
"#/initialslash": "./test.js",
27-
"#notfound": "./notfound.js"
27+
"#notfound": "./notfound.js",
28+
"#percent": "./..%2F/x.js"
2829
}
2930
}

0 commit comments

Comments
 (0)