Skip to content

Commit 6731d1b

Browse files
vsemozhetbytMylesBorins
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 842b84c commit 6731d1b

6 files changed

+12
-12
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ function runAb(opts, callback) {
2121
const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`;
2222
exec(command, function(err, stdout, stderr) {
2323
if (err) {
24-
if (/ab|apr/mi.test(stderr)) {
24+
if (/ab|apr/i.test(stderr)) {
2525
common.skip(`problem spawning \`ab\`.\n${stderr}`);
2626
process.reallyExit(0);
2727
}
2828
process.exit();
2929
return;
3030
}
3131

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

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

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

4141
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
@@ -10,7 +10,7 @@ const tls = require('tls');
1010

1111
const fs = require('fs');
1212

13-
const hosterr = /Hostname\/IP doesn't match certificate's altnames/g;
13+
const hosterr = /Hostname\/IP doesn't match certificate's altnames/;
1414
const testCases =
1515
[{ ca: ['ca1-cert'],
1616
key: 'agent2-key',

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ function runClient(prefix, port, options, cb) {
196196
client.stdout.on('data', function(d) {
197197
out += d;
198198

199-
if (!goodbye && /_unauthed/g.test(out)) {
199+
if (!goodbye && /_unauthed/.test(out)) {
200200
console.error(`${prefix} * unauthed`);
201201
goodbye = true;
202202
client.kill();
203203
authed = false;
204204
rejected = false;
205205
}
206206

207-
if (!goodbye && /_authed/g.test(out)) {
207+
if (!goodbye && /_authed/.test(out)) {
208208
console.error(`${prefix} * authed`);
209209
goodbye = true;
210210
client.kill();

test/pummel/test-keep-alive.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ function runAb(opts, callback) {
5858
return;
5959
}
6060

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

64-
matches = /Keep-Alive requests:\s*(\d+)/mi.exec(stdout);
64+
matches = /Keep-Alive requests:\s*(\d+)/i.exec(stdout);
6565
let keepAliveRequests;
6666
if (matches) {
6767
keepAliveRequests = parseInt(matches[1]);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ function test(keyfn, certfn, check, next) {
6363
console.error(state);
6464
switch (state) {
6565
case 'WAIT-ACCEPT':
66-
if (/ACCEPT/g.test(serverStdoutBuffer)) {
66+
if (/ACCEPT/.test(serverStdoutBuffer)) {
6767
// Give s_server half a second to start up.
6868
setTimeout(startClient, 500);
6969
state = 'WAIT-HELLO';
7070
}
7171
break;
7272

7373
case 'WAIT-HELLO':
74-
if (/hello/g.test(serverStdoutBuffer)) {
74+
if (/hello/.test(serverStdoutBuffer)) {
7575

7676
// End the current SSL connection and exit.
7777
// See s_server(1ssl).

0 commit comments

Comments
 (0)