Skip to content

Commit

Permalink
fix: ensure all matches of duplicate parent elements are removed in t…
Browse files Browse the repository at this point in the history
…he reassembled file, including opening tags which have the namespace in them
  • Loading branch information
mcarvin8 committed Feb 21, 2024
1 parent 847f4ed commit f9e7919
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/service/buildReassembledFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ export async function buildReassembledFile(
);

// Remove duplicate parent elements
finalXmlContent = finalXmlContent.replace(`<${xmlElement}>`, "");
finalXmlContent = finalXmlContent.replace(`</${xmlElement}>`, "");
finalXmlContent = finalXmlContent.replace(
new RegExp(
`<${xmlElement}[^>]*${xmlNamespace ? `( xmlns="${xmlNamespace}")?` : ""}>`,
"g",
),
"",
);
finalXmlContent = finalXmlContent.replace(
new RegExp(`</${xmlElement}>`, "g"),
"",
);

// Remove extra indentation within CDATA sections
finalXmlContent = finalXmlContent.replace(
Expand Down

0 comments on commit f9e7919

Please sign in to comment.