-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: refactor code with startsWith/endsWith #5753
Conversation
Did you run the relevant benchmarks before and after these changes? |
I run the os.tmpdir after change, the benchmarks have no effect. Should I do a benchmark for RegExp vs startsWith/endsWith? |
if (settings.execArgv.some(function(s) { return /^--prof/.test(s); }) && | ||
!settings.execArgv.some(function(s) { return /^--logfile=/.test(s); })) | ||
{ | ||
if (settings.execArgv.some(function(s) { |
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.
These can probably be arrow functions.
b5edadc
to
28da97f
Compare
Hi @ronkorving @benjamingr , I updated the PR with your suggestions. Thanks. |
@@ -75,7 +75,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |||
// Create regexp to much hostnames | |||
function regexpify(host, wildcards) { | |||
// Add trailing dot (make hostnames uniform) | |||
if (!/\.$/.test(host)) host += '.'; | |||
if (!host || !host.endsWith('.')) host += '.'; |
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.
What does the !host check add?
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.
the host maybe undefined
.
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 it really? In that case, the old code would have produced "undefined."
. Does that code path really exist?
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.
yes. If no !host
path, make test
will fails.
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.
Well, it wouldn't have blown up, but would've turned undefined
into "undefined"
, before appending a period to it. My point is, this was never a bug, so do we need that !host
check?
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.
We need it here.
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.
Ah, my bad. I get it now.
28da97f
to
291bc00
Compare
The windows is unhappy, I forget to check the length of string. Updated it. Would you please run CI again. |
There were multiple CI failures that appear unrelated but should be investigated before this lands. |
They say insanity is doing the same thing twice and expecting different results but I've had a long day so I'll give it another shot before investigating the CI results further: https://ci.nodejs.org/job/node-test-pull-request/2029/console |
The CI failure seems unrelated to this. Going to land. |
Wait, I just realized no one has given this a LGTM yet and I'm not completely sure about all the code involved myself - so I'd rather wait for another collaborator to LGTM it before landing. |
Ok, reviewed now and LGTM. Ping @nodejs/collaborators I'd love this to get a second review. |
!settings.execArgv.some(function(s) { return /^--logfile=/.test(s); })) | ||
{ | ||
if (settings.execArgv.some((s) => s.startsWith('--prof')) && | ||
!settings.execArgv.some((s) => s.startsWith('--logfile='))) { |
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.
The indentation here is slightly off by two spaces.
reduce using RegExp for string test.
291bc00
to
99dd39e
Compare
Thanks @benjamingr , fixed it. |
Thanks! Landed in 91466b8 |
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: #5753 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Brian White <[email protected]>
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: #5753 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Brian White <[email protected]>
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: #5753 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Brian White <[email protected]>
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: #5753 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Brian White <[email protected]>
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: #5753 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Brian White <[email protected]>
Pull Request check-list
Please make sure to review and check all of these items:
make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Affected core subsystem(s)
lib
Description of change
reduce using REGExp for string test.