This commit is contained in:
Jarek Krochmalski committed 2026-01-11 09:01:42 +01:00
1 parent c15355e159
commit 851e56bc57
23 files changed
+8923

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
/**
* Clean PEM content by removing whitespace artifacts from copy/paste.
* Bun's TLS is strict about PEM format - it fails when certificates have
* leading/trailing spaces on lines or extra blank lines.
*
* @param pem - The PEM content to clean
* @returns Cleaned PEM content with trimmed lines and no empty lines, or null if empty
*/
export function cleanPem(pem: string | null | undefined): string | null {
if (!pem) return null;
const cleaned = pem
.split('\n')
.map((line) => line.trim())
.filter((line) => line.length > 0)
.join('\n');
return cleaned.length > 0 ? cleaned : null;
}