From 9fd05e46d224d2d3a4eb73a52a1f2f7039360eb8 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Thu, 15 Jun 2017 03:33:50 +0300 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/13690 Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung Reviewed-By: Daniel Bevenius Reviewed-By: Yuta Hiroto Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-http-full-response.js | 8 ++++---- .../test-http-outgoing-first-chunk-singlebyte-encoding.js | 2 +- test/parallel/test-tls-client-verify.js | 2 +- test/parallel/test-tls-server-verify.js | 4 ++-- test/pummel/test-keep-alive.js | 4 ++-- test/pummel/test-tls-securepair-client.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-http-full-response.js b/test/parallel/test-http-full-response.js index 0e834cee5b8932..292368ae16662c 100644 --- a/test/parallel/test-http-full-response.js +++ b/test/parallel/test-http-full-response.js @@ -21,7 +21,7 @@ function runAb(opts, callback) { const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`; exec(command, function(err, stdout, stderr) { if (err) { - if (/ab|apr/mi.test(stderr)) { + if (/ab|apr/i.test(stderr)) { common.skip(`problem spawning \`ab\`.\n${stderr}`); process.reallyExit(0); } @@ -29,13 +29,13 @@ function runAb(opts, callback) { return; } - let m = /Document Length:\s*(\d+) bytes/mi.exec(stdout); + let m = /Document Length:\s*(\d+) bytes/i.exec(stdout); const documentLength = parseInt(m[1]); - m = /Complete requests:\s*(\d+)/mi.exec(stdout); + m = /Complete requests:\s*(\d+)/i.exec(stdout); const completeRequests = parseInt(m[1]); - m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout); + m = /HTML transferred:\s*(\d+) bytes/i.exec(stdout); const htmlTransfered = parseInt(m[1]); assert.strictEqual(bodyLength, documentLength); diff --git a/test/parallel/test-http-outgoing-first-chunk-singlebyte-encoding.js b/test/parallel/test-http-outgoing-first-chunk-singlebyte-encoding.js index 214287a6ffc157..f1af1dc718bd9a 100644 --- a/test/parallel/test-http-outgoing-first-chunk-singlebyte-encoding.js +++ b/test/parallel/test-http-outgoing-first-chunk-singlebyte-encoding.js @@ -24,7 +24,7 @@ for (const enc of ['utf8', 'utf16le', 'latin1', 'UTF-8']) { const headerEnd = received.indexOf('\r\n\r\n', 'utf8'); assert.notStrictEqual(headerEnd, -1); - const header = received.toString('utf8', 0, headerEnd).split(/\r\n/g); + const header = received.toString('utf8', 0, headerEnd).split(/\r\n/); const body = received.toString(enc, headerEnd + 4); assert.strictEqual(header[0], 'HTTP/1.1 200 OK'); diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js index 643126488da869..453e4f71493cf8 100644 --- a/test/parallel/test-tls-client-verify.js +++ b/test/parallel/test-tls-client-verify.js @@ -10,7 +10,7 @@ const tls = require('tls'); const fs = require('fs'); -const hosterr = /Hostname\/IP doesn't match certificate's altnames/g; +const hosterr = /Hostname\/IP doesn't match certificate's altnames/; const testCases = [{ ca: ['ca1-cert'], key: 'agent2-key', diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index eba57d65de295e..fd816ce0f9b294 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -196,7 +196,7 @@ function runClient(prefix, port, options, cb) { client.stdout.on('data', function(d) { out += d; - if (!goodbye && /_unauthed/g.test(out)) { + if (!goodbye && /_unauthed/.test(out)) { console.error(`${prefix} * unauthed`); goodbye = true; client.kill(); @@ -204,7 +204,7 @@ function runClient(prefix, port, options, cb) { rejected = false; } - if (!goodbye && /_authed/g.test(out)) { + if (!goodbye && /_authed/.test(out)) { console.error(`${prefix} * authed`); goodbye = true; client.kill(); diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index a9e91e201bb19b..f8ea1e8d4d79ab 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -58,10 +58,10 @@ function runAb(opts, callback) { return; } - let matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout); + let matches = /Requests\/sec:\s*(\d+)\./i.exec(stdout); const reqSec = parseInt(matches[1]); - matches = /Keep-Alive requests:\s*(\d+)/mi.exec(stdout); + matches = /Keep-Alive requests:\s*(\d+)/i.exec(stdout); let keepAliveRequests; if (matches) { keepAliveRequests = parseInt(matches[1]); diff --git a/test/pummel/test-tls-securepair-client.js b/test/pummel/test-tls-securepair-client.js index 0b2e45302b5cc2..234ee6a09117b0 100644 --- a/test/pummel/test-tls-securepair-client.js +++ b/test/pummel/test-tls-securepair-client.js @@ -63,7 +63,7 @@ function test(keyfn, certfn, check, next) { console.error(state); switch (state) { case 'WAIT-ACCEPT': - if (/ACCEPT/g.test(serverStdoutBuffer)) { + if (/ACCEPT/.test(serverStdoutBuffer)) { // Give s_server half a second to start up. setTimeout(startClient, 500); state = 'WAIT-HELLO'; @@ -71,7 +71,7 @@ function test(keyfn, certfn, check, next) { break; case 'WAIT-HELLO': - if (/hello/g.test(serverStdoutBuffer)) { + if (/hello/.test(serverStdoutBuffer)) { // End the current SSL connection and exit. // See s_server(1ssl).