Skip to content

Commit

Permalink
test: refactor test-tls-cert-chains-in-ca
Browse files Browse the repository at this point in the history
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: #11367
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
  • Loading branch information
Trott authored and italoacasas committed Feb 22, 2017
1 parent 6a2f330 commit f495389
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions test/parallel/test-tls-cert-chains-in-ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit f495389

Please sign in to comment.