Skip to content

Commit

Permalink
Address review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RDPerera committed Jan 18, 2024
1 parent 7bcc3f7 commit d88fbcd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ballerina/segment_group_reader.bal
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ isolated function readSegmentGroup(EdiUnitSchema[] currentUnitSchema, EdiContext
if segSchema is () {
return error Error("Segment schema cannot be empty.");
}
string sDesc = context.ediText[context.rawIndex];
string:RegExp newline = re `\n`;
string segmentDesc = newline.replaceAll(sDesc, "");
string segmentDesc = removeLineBreaks(context.ediText[context.rawIndex]);
// There can be segments that do not follow standard EDI format (e.g. EDIFACT UNA segment).
// Therefore, it is necessary to check and skip ignore segments before spliting into fields.
boolean ignoreCurrentSegment = false;
Expand Down
7 changes: 5 additions & 2 deletions ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ isolated function splitSegments(string text, string delimiter) returns string[]|
if segmentLines[segmentLines.length() - 1] == "" {
string _ = segmentLines.remove(segmentLines.length() - 1);
}
string:RegExp newline = re `\n`;
foreach int i in 0 ... (segmentLines.length() - 1) {
segmentLines[i] = newline.replaceAll(segmentLines[i], "");
segmentLines[i] = removeLineBreaks(segmentLines[i]);
}
return segmentLines;
}
Expand Down Expand Up @@ -261,3 +260,7 @@ isolated function addPadding(string value, int requiredLength) returns string {
return paddedValue;
}

isolated function removeLineBreaks(string value) returns string {
string:RegExp newline = re `\n`;
return newline.replaceAll(value, "");
}

0 comments on commit d88fbcd

Please sign in to comment.