From 9064a5ecf7225e67c73941b460e861b686cab149 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Tue, 15 Feb 2022 23:51:25 -0500 Subject: [PATCH] fix: trim random newlines between packages --- src/packages.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/packages.ts b/src/packages.ts index f24475b..2830d39 100644 --- a/src/packages.ts +++ b/src/packages.ts @@ -124,6 +124,12 @@ export class Packages extends Array { constructor(rawData: string) { const cleanedData = rawData.replaceAll(/\r\n|\r|\n/g, '\n').replaceAll(/\0/g, '').normalize().trim() const packageChunks = cleanedData.split('\n\n') // We know it will always be \n\n because of our cleanup - super(...packageChunks.map(chunk => new Package(chunk))) + + const cleanedArray = packageChunks.map(chunk => { + if (chunk.trim().length > 0) { + return new Package(chunk) + } + }).filter(item => item) as Package[] + super(...cleanedArray) } }