From 03197a9bc8790f26705f0ce0863dfb7bcdc7937f Mon Sep 17 00:00:00 2001 From: notroid5 <87585310+notroid5@users.noreply.github.com> Date: Tue, 7 Dec 2021 12:45:04 +0100 Subject: [PATCH] doc: clarify escaping for ES modules This should make it clear(er) how to escape special characters like `#` and `?`. Ref: https://github.com/nodejs/node/issues/41052 PR-URL: https://github.com/nodejs/node/pull/41074 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca --- doc/api/esm.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 00c0bfa860aa86..3ff28d5e913a8c 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -150,8 +150,8 @@ typically configured server. ### URLs -ES modules are resolved and cached as URLs. This means that files containing -special characters such as `#` and `?` need to be escaped. +ES modules are resolved and cached as URLs. This means that special characters +must be [percent-encoded][], such as `#` with `%23` and `?` with `%3F`. `file:`, `node:`, and `data:` URL schemes are supported. A specifier like `'https://example.com/app.js'` is not supported natively in Node.js unless using @@ -1432,6 +1432,7 @@ success! [cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2 [custom https loader]: #https-loader [load hook]: #loadurl-context-defaultload +[percent-encoded]: url.md#percent-encoding-in-urls [resolve hook]: #resolvespecifier-context-defaultresolve [special scheme]: https://url.spec.whatwg.org/#special-scheme [the official standard format]: https://tc39.github.io/ecma262/#sec-modules