From e2d7df6fdca6620a85981afef522255b571eafcd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 13 Feb 2017 20:29:33 -0800 Subject: [PATCH] test: refactor test-tls-cert-chains-in-ca When splitting PEM string into separate certs, use non-capturing regexp to avoid having to put the split string back with .map(). As a bonus, this splits the PEM into two certs, rather than 2 certs and a third crufty whitespace-only string. PR-URL: https://github.com/nodejs/node/pull/11367 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sam Roberts --- test/parallel/test-tls-cert-chains-in-ca.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/parallel/test-tls-cert-chains-in-ca.js b/test/parallel/test-tls-cert-chains-in-ca.js index 69f62c3f72..3b4e78919f 100644 --- a/test/parallel/test-tls-cert-chains-in-ca.js +++ b/test/parallel/test-tls-cert-chains-in-ca.js @@ -12,8 +12,7 @@ const { // agent6-cert.pem includes cert for agent6 and ca3, split it apart and // provide ca3 in the .ca property. -const agent6Chain = keys.agent6.cert.split('-----END CERTIFICATE-----') - .map((c) => { return c + '-----END CERTIFICATE-----'; }); +const agent6Chain = keys.agent6.cert.split(/(?=-----BEGIN CERTIFICATE-----)/); const agent6End = agent6Chain[0]; const agent6Middle = agent6Chain[1]; connect({