doc: clarify escaping for ES modules#41074
doc: clarify escaping for ES modules#41074nodejs-github-bot merged 1 commit intonodejs:masterfrom notroid5:patch-1
Conversation
doc/api/esm.md
Outdated
|
|
||
| ES modules are resolved and cached as URLs. This means that files containing | ||
| special characters such as `#` and `?` need to be escaped. | ||
| special characters need to be replaced with escape sequences, such as `#` with `%23` and `?` with `%3F`. |
There was a problem hiding this comment.
| special characters need to be replaced with escape sequences, such as `#` with `%23` and `?` with `%3F`. | |
| special characters must be [percent-encoded][], such as `#` with `%23` and `?` with `%3F`. |
Then add a new reference at the bottom of the esm.md to:
[percent-encoded]: url.md#percent-encoding-in-urlsThere was a problem hiding this comment.
Maybe either the bit being changed or the percent-encoding-in-urls section of url.md could point to encodeURIComponent()?
There was a problem hiding this comment.
Maybe either the bit being changed or the
percent-encoding-in-urlssection ofurl.mdcould point toencodeURIComponent()?
Or https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding?
There was a problem hiding this comment.
I'd say the link to url.md#percent-encoding-in-urls suffices here.
The other links could then be referenced in url.md#percent-encoding-in-urls. (https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)
|
cc @nodejs/modules |
| ES modules are resolved and cached as URLs. This means that files containing | ||
| special characters such as `#` and `?` need to be escaped. |
There was a problem hiding this comment.
FWIW, the word escape does not appear in the relevant MDN doc, so maybe "encoded" is the way to go instead of "escaped" or "replaced with escape sequences". Also, and I know this wasn't introduced in this PR, but "files containing" makes it sound we're talking about the file contents when we're talking about the URL.
| 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 characters such as | |
| `#` and `?` need to be [percent-encoded][]. |
Then add to the bottom:
[percent-encoding]: https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding
This should make it clear(er) how to escape special characters like `#` and `?`. Ref: #41052
|
Landed in 3d5a7de |
This should make it clear(er) how to escape special characters like `#` and `?`. Ref: nodejs#41052 PR-URL: nodejs#41074 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Change proposed according to #41052
This should make it clear how to escape special characters like
#.I don't know if there are any more, though.
Also, how you would call this in general?
I found it as "Javascript Escape Sequence", is this a known term?
(Also, the first link below contains a dot at the end:
https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md.That should probably be removed.)
Edit: Changed text slightly, so the next check should be successful.