| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f281946 commit 3fe37e6
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,9 +96,11 @@ function createConnection(port, host, options) { | |||
| 96 | 96 | if (port !== null && typeof port === 'object') { | |
| 97 | 97 | options = port; | |
| 98 | 98 | } else if (host !== null && typeof host === 'object') { | |
| 99 | - options = host; | ||
| 99 | + options = { ...host }; | ||
| 100 | 100 | } else if (options === null || typeof options !== 'object') { | |
| 101 | 101 | options = {}; | |
| 102 | + } else { | ||
| 103 | + options = { ...options }; | ||
| 102 | 104 | } | |
| 103 | 105 | ||
| 104 | 106 | if (typeof port === 'number') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,3 +132,27 @@ function createServer() { | |||
| 132 | 132 | })); | |
| 133 | 133 | })); | |
| 134 | 134 | } | |
| 135 | + | ||
| 136 | + // `options` should not be modified | ||
| 137 | + { | ||
| 138 | + const server = createServer(); | ||
| 139 | + server.listen(0, common.mustCall(() => { | ||
| 140 | + const port = server.address().port; | ||
| 141 | + const host = 'localhost'; | ||
| 142 | + const options = { | ||
| 143 | + port: 3000, | ||
| 144 | + rejectUnauthorized: false | ||
| 145 | + }; | ||
| 146 | + | ||
| 147 | + const socket = agent.createConnection(port, host, options); | ||
| 148 | + socket.on('connect', common.mustCall((data) => { | ||
| 149 | + socket.end(); | ||
| 150 | + })); | ||
| 151 | + socket.on('end', common.mustCall(() => { | ||
| 152 | + assert.deepStrictEqual(options, { | ||
| 153 | + port: 3000, rejectUnauthorized: false | ||
| 154 | + }); | ||
| 155 | + server.close(); | ||
| 156 | + })); | ||
| 157 | + })); | ||
| 158 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments