Skip to content

Commit 0e857a5

Browse files
vsemozhetbytaddaleax
authored andcommitted
test: remove needless RegExp flags
* /m is needless if ^ and $ are not used * /g is needless in split() * /g is needless in test() with one-time RegExp/String PR-URL: #13690 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e30fc2c commit 0e857a5

7 files changed

+13
-13
lines changed

test/parallel/test-http-full-response.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ function runAb(opts, callback) {
4242
const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`;
4343
exec(command, function(err, stdout, stderr) {
4444
if (err) {
45-
if (/ab|apr/mi.test(stderr)) {
45+
if (/ab|apr/i.test(stderr)) {
4646
common.skip(`problem spawning \`ab\`.\n${stderr}`);
4747
process.reallyExit(0);
4848
}
4949
process.exit();
5050
return;
5151
}
5252

53-
let m = /Document Length:\s*(\d+) bytes/mi.exec(stdout);
53+
let m = /Document Length:\s*(\d+) bytes/i.exec(stdout);
5454
const documentLength = parseInt(m[1]);
5555

56-
m = /Complete requests:\s*(\d+)/mi.exec(stdout);
56+
m = /Complete requests:\s*(\d+)/i.exec(stdout);
5757
const completeRequests = parseInt(m[1]);
5858

59-
m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
59+
m = /HTML transferred:\s*(\d+) bytes/i.exec(stdout);
6060
const htmlTransfered = parseInt(m[1]);
6161

6262
assert.strictEqual(bodyLength, documentLength);

test/parallel/test-http-outgoing-first-chunk-singlebyte-encoding.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for (const enc of ['utf8', 'utf16le', 'latin1', 'UTF-8']) {
2424
const headerEnd = received.indexOf('\r\n\r\n', 'utf8');
2525
assert.notStrictEqual(headerEnd, -1);
2626

27-
const header = received.toString('utf8', 0, headerEnd).split(/\r\n/g);
27+
const header = received.toString('utf8', 0, headerEnd).split(/\r\n/);
2828
const body = received.toString(enc, headerEnd + 4);
2929

3030
assert.strictEqual(header[0], 'HTTP/1.1 200 OK');

test/parallel/test-tls-client-verify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const tls = require('tls');
3131

3232
const fs = require('fs');
3333

34-
const hosterr = /Hostname\/IP doesn't match certificate's altnames/g;
34+
const hosterr = /Hostname\/IP doesn't match certificate's altnames/;
3535
const testCases =
3636
[{ ca: ['ca1-cert'],
3737
key: 'agent2-key',

test/parallel/test-tls-server-verify.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ function runClient(prefix, port, options, cb) {
217217
client.stdout.on('data', function(d) {
218218
out += d;
219219

220-
if (!goodbye && /_unauthed/g.test(out)) {
220+
if (!goodbye && /_unauthed/.test(out)) {
221221
console.error(`${prefix} * unauthed`);
222222
goodbye = true;
223223
client.kill();
224224
authed = false;
225225
rejected = false;
226226
}
227227

228-
if (!goodbye && /_authed/g.test(out)) {
228+
if (!goodbye && /_authed/.test(out)) {
229229
console.error(`${prefix} * authed`);
230230
goodbye = true;
231231
client.kill();

test/parallel/test-util-callbackify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const values = [
205205
assert.strictEqual(err.code, 1);
206206
assert.strictEqual(Object.getPrototypeOf(err).name, 'Error');
207207
assert.strictEqual(stdout, '');
208-
const errLines = stderr.trim().split(/[\r\n]+/g);
208+
const errLines = stderr.trim().split(/[\r\n]+/);
209209
const errLine = errLines.find((l) => /^Error/.exec(l));
210210
assert.strictEqual(errLine, `Error: ${fixture}`);
211211
})

test/pummel/test-keep-alive.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ function runAb(opts, callback) {
7979
return;
8080
}
8181

82-
let matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout);
82+
let matches = /Requests\/sec:\s*(\d+)\./i.exec(stdout);
8383
const reqSec = parseInt(matches[1]);
8484

85-
matches = /Keep-Alive requests:\s*(\d+)/mi.exec(stdout);
85+
matches = /Keep-Alive requests:\s*(\d+)/i.exec(stdout);
8686
let keepAliveRequests;
8787
if (matches) {
8888
keepAliveRequests = parseInt(matches[1]);

test/pummel/test-tls-securepair-client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ function test(keyfn, certfn, check, next) {
8484
console.error(state);
8585
switch (state) {
8686
case 'WAIT-ACCEPT':
87-
if (/ACCEPT/g.test(serverStdoutBuffer)) {
87+
if (/ACCEPT/.test(serverStdoutBuffer)) {
8888
// Give s_server half a second to start up.
8989
setTimeout(startClient, 500);
9090
state = 'WAIT-HELLO';
9191
}
9292
break;
9393

9494
case 'WAIT-HELLO':
95-
if (/hello/g.test(serverStdoutBuffer)) {
95+
if (/hello/.test(serverStdoutBuffer)) {
9696

9797
// End the current SSL connection and exit.
9898
// See s_server(1ssl).

0 commit comments

Comments
 (0)