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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
  • Loading branch information
Trott committed Feb 16, 2017
1 parent 3429991 commit e2d7df6
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 e2d7df6

Please sign in to comment.