Skip to content

Commit

Permalink
fix: trim random newlines between packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tale committed Feb 16, 2022
1 parent a645020 commit 9064a5e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export class Packages extends Array<Package> {
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)
}
}

0 comments on commit 9064a5e

Please sign in to comment.