Skip to content

Commit aa52944

Browse files
committed
fix parser config
1 parent ec3d133 commit aa52944

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-xml-stub.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ const compareEquivalentXmlBodies = (
88
): Object => {
99
const parseConfig = {
1010
attributeNamePrefix: "",
11+
htmlEntities: true,
1112
ignoreAttributes: false,
13+
ignoreDeclaration: true,
1214
parseTagValue: false,
1315
trimValues: false,
14-
tagValueProcessor: (val: any, tagName: any) =>
15-
val.trim() === "" ? "" : decodeHTML(val),
16+
tagValueProcessor: (_, val) => (val.trim() === "" && val.includes("\n") ? "" : undefined),
1617
};
1718

1819
const parseXmlBody = (body: string) => {
19-
const parsedObj = new XMLParser(parseConfig).parse(body);
20+
const parser = new XMLParser(parseConfig);
21+
parser.addEntity("#xD", "\r");
22+
parser.addEntity("#10", "\n");
23+
const parsedObj = parser.parse(body);
2024
const textNodeName = "#text";
2125
const key = Object.keys(parsedObj)[0];
2226
const parsedObjToReturn = parsedObj[key];

0 commit comments

Comments
 (0)