tastypackets / x12-parser

JavaScript EDI Parser that uses datastreams
MIT License
43 stars 9 forks source link

Fix chunking error edge case #21

Closed SirCoolness closed 1 year ago

SirCoolness commented 1 year ago

There is a weird edge case where if a chunk ends with a segment delimiter, it merges with the next segment.

This fix should solve the problem by only adding to the existing code. But this is not the cleanest fix.

The better fix would be to not strip the trailing segment delimiter in removeDelimiters. Because even when the string is split, the last element is empty.

My main reason for solving the problem the way I did, was in case I misunderstood something about the spec.

I also added unit testing to demonstrate this issue and that the problem is solved.

tastypackets commented 1 year ago

Thanks for the PR! For some reason I wasn't getting GitHub notifications and I haven't worked with EDI/X12 in a few years, so I wasn't watching this repo. I'm updating the old tooling right now and then will take a look at this patch. 👍

tastypackets commented 1 year ago

Since I changed the default branch to main I opened a new PR for this fix.