commit
33bdb09b1b
@ -20,7 +20,7 @@ export class V2XmlFormatter implements XmlFormatter {
|
|||||||
xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes
|
xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes
|
||||||
xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>)
|
xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>)
|
||||||
xml = xml.replace(/"\s+(?=\/>)/g, "\" "); // spaces between the last attribute and tag close (/>)
|
xml = xml.replace(/"\s+(?=\/>)/g, "\" "); // spaces between the last attribute and tag close (/>)
|
||||||
xml = xml.replace(/[^ <>="]\s+[^ <>="]+=/g, (match: string) => { // spaces between the node name and the first attribute
|
xml = xml.replace(/(?!<!\[CDATA\[)[^ <>="]\s+[^ <>="]+=(?![^<]*?\]\]>)/g, (match: string) => { // spaces between the node name and the first attribute
|
||||||
return match.replace(/\s+/g, " ");
|
return match.replace(/\s+/g, " ");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@ describe("V2XmlFormatter", () => {
|
|||||||
testFormatter(xmlFormatter, options, "issue-200");
|
testFormatter(xmlFormatter, options, "issue-200");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not remove spaces between the node name and the first attribute within CDATA", () => {
|
||||||
|
testFormatter(xmlFormatter, options, "issue-227");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
19
src/test/test-data/issue-227.formatted.xml
Normal file
19
src/test/test-data/issue-227.formatted.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<Job>
|
||||||
|
<SQLQuery test="">
|
||||||
|
<SQLSelect Test="test" test="test">
|
||||||
|
<![CDATA[
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from test
|
||||||
|
where
|
||||||
|
aaa.aaa='AAA' and
|
||||||
|
isnull(BBB.BBB,0)=0 and
|
||||||
|
isnull(CCTestC.CCC,0)=1 and
|
||||||
|
DDD.DDD is null and
|
||||||
|
exists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and
|
||||||
|
exists (select 1 from FFF where FFF.FFF=FFF.FFF) and
|
||||||
|
'{GGG}' like '%'+GGG.GGG+'%'
|
||||||
|
]]>
|
||||||
|
</SQLSelect>
|
||||||
|
</SQLQuery>
|
||||||
|
</Job>
|
19
src/test/test-data/issue-227.unformatted.xml
Normal file
19
src/test/test-data/issue-227.unformatted.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<Job>
|
||||||
|
<SQLQuery test="">
|
||||||
|
<SQLSelect Test="test" test="test">
|
||||||
|
<![CDATA[
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from test
|
||||||
|
where
|
||||||
|
aaa.aaa='AAA' and
|
||||||
|
isnull(BBB.BBB,0)=0 and
|
||||||
|
isnull(CCTestC.CCC,0)=1 and
|
||||||
|
DDD.DDD is null and
|
||||||
|
exists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and
|
||||||
|
exists (select 1 from FFF where FFF.FFF=FFF.FFF) and
|
||||||
|
'{GGG}' like '%'+GGG.GGG+'%'
|
||||||
|
]]>
|
||||||
|
</SQLSelect>
|
||||||
|
</SQLQuery>
|
||||||
|
</Job>
|
Loading…
Reference in New Issue
Block a user