Skip to content

Error importing ES module with an encoded comma in the URL #40305

Description

@fasttime

Version

v16.10.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

// test.mjs
import './foo%2cbar.mjs';

or

// test2.mjs
await import('./foo%2cbar.mjs');

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Should import a module named "foo,bar.mjs" located in the same folder, if present, or throw an error with code ERR_MODULE_NOT_FOUND.

What do you see instead?

Throws:

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "./foo%2cbar.mjs" must not include encoded "/" or "\" characters imported from ./test.mjs

Note that there is no encoded "/" or "\" in "./foo%2cbar.mjs", just an encoded ","!

Additional information

In my understanding, this behavior results from a bug in lib/internal/modules/esm/resolve.js, where the regular expression encodedSepRegEx incorrectly matches an encoded slash or comma ("/" or ",") instead of a slash or backslash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions