| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4c9f2b5 commit 0413736
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,10 +296,14 @@ the agent when `keepAlive` is enabled. Do not modify. | |||
| 296 | 296 | Sockets in the `freeSockets` list will be automatically destroyed and | |
| 297 | 297 | removed from the array on `'timeout'`. | |
| 298 | 298 | ||
| 299 | - ### `agent.getName(options)` | ||
| 299 | + ### `agent.getName([options])` | ||
| 300 | 300 | ||
| 301 | 301 | <!-- YAML | |
| 302 | 302 | added: v0.11.4 | |
| 303 | + changes: | ||
| 304 | + - version: REPLACEME | ||
| 305 | + pr-url: https://github.com/nodejs/node/pull/41906 | ||
| 306 | + description: The `options` parameter is now optional. | ||
| 303 | 307 | --> | |
| 304 | 308 | ||
| 305 | 309 | * `options` {Object} A set of options providing information for name generation | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,7 +217,7 @@ Agent.defaultMaxSockets = Infinity; | |||
| 217 | 217 | Agent.prototype.createConnection = net.createConnection; | |
| 218 | 218 | ||
| 219 | 219 | // Get the key for a given set of request options | |
| 220 | - Agent.prototype.getName = function getName(options) { | ||
| 220 | + Agent.prototype.getName = function getName(options = {}) { | ||
| 221 | 221 | let name = options.host || 'localhost'; | |
| 222 | 222 | ||
| 223 | 223 | name += ':'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -203,7 +203,7 @@ Agent.prototype.createConnection = createConnection; | |||
| 203 | 203 | * }} [options] | |
| 204 | 204 | * @returns {string} | |
| 205 | 205 | */ | |
| 206 | - Agent.prototype.getName = function getName(options) { | ||
| 206 | + Agent.prototype.getName = function getName(options = {}) { | ||
| 207 | 207 | let name = FunctionPrototypeCall(HttpAgent.prototype.getName, this, options); | |
| 208 | 208 | ||
| 209 | 209 | name += ':'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,13 @@ assert.strictEqual( | |||
| 18 | 18 | 'localhost:80:192.168.1.1' | |
| 19 | 19 | ); | |
| 20 | 20 | ||
| 21 | - // empty | ||
| 21 | + // empty argument | ||
| 22 | + assert.strictEqual( | ||
| 23 | + agent.getName(), | ||
| 24 | + 'localhost::' | ||
| 25 | + ); | ||
| 26 | + | ||
| 27 | + // empty options | ||
| 22 | 28 | assert.strictEqual( | |
| 23 | 29 | agent.getName({}), | |
| 24 | 30 | 'localhost::' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,12 @@ const https = require('https'); | |||
| 9 | 9 | ||
| 10 | 10 | const agent = new https.Agent(); | |
| 11 | 11 | ||
| 12 | + // empty argument | ||
| 13 | + assert.strictEqual( | ||
| 14 | + agent.getName(), | ||
| 15 | + 'localhost::::::::::::::::::::::' | ||
| 16 | + ); | ||
| 17 | + | ||
| 12 | 18 | // empty options | |
| 13 | 19 | assert.strictEqual( | |
| 14 | 20 | agent.getName({}), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments