Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2022-04-20 11:23:41 +0300
committerGitHub <noreply@github.com>2022-04-20 11:23:41 +0300
commit6afd3fcf653ed92063bafefa83661a076d241585 (patch)
tree9e1a22ab2f3d3cf1f14ec2348ca0a318fef16898 /doc/api/https.md
parent1fe5d56403a3725eac5e67c7a08830ce5ee0e2f5 (diff)
doc: add `node:` prefix for all core modules
Some core modules can be loaded with or without the `node:` prefix. Using the prefix disambiguates which specifiers refer to core modules. This commit updates the docs to use the prefix everywhere a core module is referenced. PR-URL: https://github.com/nodejs/node/pull/42752 Fixes: https://github.com/nodejs/node/issues/38343 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'doc/api/https.md')
-rw-r--r--doc/api/https.md26
1 files changed, 13 insertions, 13 deletions
diff --git a/doc/api/https.md b/doc/api/https.md
index d7d47cf07bc..c022bc7ee30 100644
--- a/doc/api/https.md
+++ b/doc/api/https.md
@@ -12,8 +12,8 @@ separate module.
## Determining if crypto support is unavailable
It is possible for Node.js to be built without including support for the
-`crypto` module. In such cases, attempting to `import` from `https` or
-calling `require('https')` will result in an error being thrown.
+`node:crypto` module. In such cases, attempting to `import` from `https` or
+calling `require('node:https')` will result in an error being thrown.
When using CommonJS, the error thrown can be caught using try/catch:
@@ -22,7 +22,7 @@ When using CommonJS, the error thrown can be caught using try/catch:
```cjs
let https;
try {
- https = require('https');
+ https = require('node:https');
} catch (err) {
console.log('https support is disabled!');
}
@@ -40,7 +40,7 @@ of Node.js where crypto support is not enabled, consider using the
```mjs
let https;
try {
- https = await import('https');
+ https = await import('node:https');
} catch (err) {
console.log('https support is disabled!');
}
@@ -215,8 +215,8 @@ added: v0.3.4
```js
// curl -k https://localhost:8000/
-const https = require('https');
-const fs = require('fs');
+const https = require('node:https');
+const fs = require('node:fs');
const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
@@ -232,8 +232,8 @@ https.createServer(options, (req, res) => {
Or
```js
-const https = require('https');
-const fs = require('fs');
+const https = require('node:https');
+const fs = require('node:fs');
const options = {
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
@@ -274,7 +274,7 @@ string, it is automatically parsed with [`new URL()`][]. If it is a [`URL`][]
object, it will be automatically converted to an ordinary `options` object.
```js
-const https = require('https');
+const https = require('node:https');
https.get('https://encrypted.google.com/', (res) => {
console.log('statusCode:', res.statusCode);
@@ -353,7 +353,7 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
upload a file with a POST request, then write to the `ClientRequest` object.
```js
-const https = require('https');
+const https = require('node:https');
const options = {
hostname: 'encrypted.google.com',
@@ -427,9 +427,9 @@ Example pinning on certificate fingerprint, or the public key (similar to
`pin-sha256`):
```js
-const tls = require('tls');
-const https = require('https');
-const crypto = require('crypto');
+const tls = require('node:tls');
+const https = require('node:https');
+const crypto = require('node:crypto');
function sha256(s) {
return crypto.createHash('sha256').update(s).digest('base64');