From a5c9047c89c7575fed158ebea74f30c0f21b964b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20De=20Caluw=C3=A9?= Date: Mon, 7 Mar 2016 02:29:03 +0100 Subject: [PATCH] Fix #17 by removing the break after UNA detection. --- package.json | 2 +- parser.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec16341..7afacda 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "edifact" -, "version": "1.2.5" +, "version": "1.2.6" , "description": "JavaScript parser for UN/EDIFACT documents." , "keywords": ["edifact", "edi", "eancom"] , "main": "index.js" diff --git a/parser.js b/parser.js index 697b948..abcccb2 100644 --- a/parser.js +++ b/parser.js @@ -114,8 +114,11 @@ Parser.prototype.write = function (chunk) { switch (this.state) { case Parser.states.empty: index = this.una(chunk) ? 9 : 0; + // If the first segment is interrupted by, for example, a line break, the + // parser will remain in the same state as it has here. Since we don't + // want the parser to detect another UNA header, in such a case, we put it + // in the segment state. this.state = Parser.states.segment; - break; case Parser.states.segment: index = this._tokenizer.segment(chunk, index); // Determine the next parser state.