From 6274eb78fb6ee0c216885c1f88d1b5acbf399dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Sun, 30 Nov 2025 13:06:30 +0000 Subject: [PATCH 1/2] test: use `assert.match` for non-literal regexp tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/60879 Refs: https://github.com/nodejs/node/pull/60832 Reviewed-By: Antoine du Hamel Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso --- test/parallel/test-max-old-space-size-percentage.js | 4 ++-- test/parallel/test-tls-junk-server.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-max-old-space-size-percentage.js b/test/parallel/test-max-old-space-size-percentage.js index b84344ddb3988d..c5071d2f959ce3 100644 --- a/test/parallel/test-max-old-space-size-percentage.js +++ b/test/parallel/test-max-old-space-size-percentage.js @@ -41,7 +41,7 @@ invalidPercentages.forEach((input) => { `--max-old-space-size-percentage=${input[0]}`, ], { stdio: ['pipe', 'pipe', 'pipe'] }); assert.notStrictEqual(result.status, 0, `Expected non-zero exit for invalid input ${input[0]}`); - assert(input[1].test(result.stderr.toString()), `Unexpected error message for invalid input ${input[0]}`); + assert.match(result.stderr.toString(), input[1]); }); // Test NODE_OPTIONS with valid percentages @@ -61,7 +61,7 @@ invalidPercentages.forEach((input) => { env: { ...process.env, NODE_OPTIONS: `--max-old-space-size-percentage=${input[0]}` } }); assert.notStrictEqual(result.status, 0, `NODE_OPTIONS: Expected non-zero exit for invalid input ${input[0]}`); - assert(input[1].test(result.stderr.toString()), `NODE_OPTIONS: Unexpected error message for invalid input ${input[0]}`); + assert.match(result.stderr.toString(), input[1]); }); // Test percentage calculation validation diff --git a/test/parallel/test-tls-junk-server.js b/test/parallel/test-tls-junk-server.js index ff491d11a18c3e..a349c35494588b 100644 --- a/test/parallel/test-tls-junk-server.js +++ b/test/parallel/test-tls-junk-server.js @@ -28,7 +28,7 @@ server.listen(0, common.mustCall(function() { expectedErrorMessage = new RegExp('packet length too long'); }; req.once('error', common.mustCall(function(err) { - assert(expectedErrorMessage.test(err.message)); + assert.match(err.message, expectedErrorMessage); server.close(); })); })); From d0c102495a5958d2cce1b42ed9cd45eddbafac7f Mon Sep 17 00:00:00 2001 From: schliepa Date: Sun, 30 Nov 2025 14:31:56 +0100 Subject: [PATCH 2/2] doc: show the use of string expressions in the SQLTagStore example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a users attempts to escape strings with quotes in SQLTagStore template strings (`'${expression}'`), as is usually required for SQL query strings, the queries would fail. This change shows an example on the correct use (`${expression}`). PR-URL: https://github.com/nodejs/node/pull/60873 Reviewed-By: René Reviewed-By: Colin Ihrig --- doc/api/sqlite.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index dec01a512b9cef..60fa4453d09817 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -550,8 +550,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`; sql.run`INSERT INTO users VALUES (2, 'Bob')`; // Using the 'get' method to retrieve a single row. -const id = 1; -const user = sql.get`SELECT * FROM users WHERE id = ${id}`; +const name = 'Alice'; +const user = sql.get`SELECT * FROM users WHERE name = ${name}`; console.log(user); // { id: 1, name: 'Alice' } // Using the 'all' method to retrieve all rows. @@ -577,8 +577,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`; sql.run`INSERT INTO users VALUES (2, 'Bob')`; // Using the 'get' method to retrieve a single row. -const id = 1; -const user = sql.get`SELECT * FROM users WHERE id = ${id}`; +const name = 'Alice'; +const user = sql.get`SELECT * FROM users WHERE name = ${name}`; console.log(user); // { id: 1, name: 'Alice' } // Using the 'all' method to retrieve all rows.