Skip to content

splitPemBlocks

Finds all BEGIN/END-delimited PEM blocks in a string and returns them as parsed PemBlock entries. Handles concatenated PEM files and ignores non-PEM text between blocks.

Returns a typed failure (code: 'malformed') on stray or truncated PEM markers. For the throwing form use splitPemBlocksOrThrow.

ts
function splitPemBlocks(
	input: string,
): SplitPemBlocksResult

Parameters

  • input: string

Released under the MIT License.