Skip to content

Commit

Permalink
Merge pull request #10 from wes4m/windows_cr_fix
Browse files Browse the repository at this point in the history
Windows \r\n fix
  • Loading branch information
wes4m authored Oct 18, 2022
2 parents 56b4300 + 324af4b commit ec18c94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/zatca/signing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export const getCertificateInfo = (certificate_string: string): {hash: string, i
* @returns String base64 encoded certificate body.
*/
export const cleanUpCertificateString = (certificate_string: string): string => {
return certificate_string.replace("-----BEGIN CERTIFICATE-----\n", "").replace("-----END CERTIFICATE-----", "").trim()
const r = process.platform === "win32" ? "\r" : "";
return certificate_string.replace(`-----BEGIN CERTIFICATE-----${r}\n`, "").replace("-----END CERTIFICATE-----", "").trim()
}

/**
Expand All @@ -127,7 +128,8 @@ export const cleanUpCertificateString = (certificate_string: string): string =>
* @returns String base64 encoded private key body.
*/
export const cleanUpPrivateKeyString = (certificate_string: string): string => {
return certificate_string.replace("-----BEGIN EC PRIVATE KEY-----\n", "").replace("-----END EC PRIVATE KEY-----", "").trim()
const r = process.platform === "win32" ? "\r" : "";
return certificate_string.replace(`-----BEGIN EC PRIVATE KEY-----${r}\n`, "").replace("-----END EC PRIVATE KEY-----", "").trim()
}


Expand Down

0 comments on commit ec18c94

Please sign in to comment.