-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: added net.connect lookup type check #11873
test: added net.connect lookup type check #11873
Conversation
Check the options passed to the connect function of Socket to validate the type of the lookupmproperty. It must be strictly a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Few nits.
|
||
const expectedError = /^TypeError: "lookup" option should be a function$/; | ||
|
||
['foobar', 1, {}, []].forEach((input => { connectThrows(input); })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a ;
at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also.. the {
and ; }
around connectThrows(input)
can be dropped.
['foobar', 1, {}, []].forEach((input => { connectThrows(input); })) | ||
|
||
function connectThrows(input) { | ||
var opts = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/var/const
@@ -5,10 +5,10 @@ const net = require('net'); | |||
|
|||
const expectedError = /^TypeError: "lookup" option should be a function$/; | |||
|
|||
['foobar', 1, {}, []].forEach((input => { connectThrows(input); })) | |||
['foobar', 1, {}, []].forEach((input => connectThrows(input) )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the extra parens around the arrow function here and on line 22 be removed?
const opts = { | ||
host: 'localhost', | ||
port: common.PORT, | ||
lookup: input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should remove the comma here. Is this passing make lint
?
const opts = { | ||
host: 'localhost', | ||
port: common.PORT, | ||
lookup: input, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
|
||
const expectedError = /^TypeError: "lookup" option should be a function$/; | ||
|
||
['foobar', 1, {}, []].forEach((input) => connectThrows(input)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: how about adding other primitives (boolean
, undefined
, symbol
)?
Landed in 1ff6796. Thanks. |
Check the options passed to Socket.prototype.connect() to validate the type of the lookup property. PR-URL: #11873 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Check the options passed to Socket.prototype.connect() to validate the type of the lookup property. PR-URL: nodejs#11873 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This PR need backport to v7 |
Landed cleanly on v6.x (it's a new file, not sure why it needed a backport to v7). |
Check the options passed to Socket.prototype.connect() to validate the type of the lookup property. PR-URL: #11873 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Check the options passed to Socket.prototype.connect() to validate the type of the lookup property. PR-URL: #11873 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Check the options passed to the Socket connect function to validate
the type of the lookup property. It must be strictly a function.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test net