File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @astrojs/rss ' : patch
3+ ---
4+
5+ Preserve self-closing tags in ` customData ` option
Original file line number Diff line number Diff line change @@ -142,7 +142,13 @@ async function generateRSS(rssOptions: ValidatedRSSOptions): Promise<string> {
142142 ? rssOptions . items
143143 : rssOptions . items . filter ( ( item ) => ! item . draft ) ;
144144
145- const xmlOptions = { ignoreAttributes : false } ;
145+ const xmlOptions = {
146+ ignoreAttributes : false ,
147+ // Avoid correcting self-closing tags to standard tags
148+ // when using `customData`
149+ // https://github.com/withastro/astro/issues/5794
150+ suppressEmptyNode : true ,
151+ } ;
146152 const parser = new XMLParser ( xmlOptions ) ;
147153 const root : any = { '?xml' : { '@_version' : '1.0' , '@_encoding' : 'UTF-8' } } ;
148154 if ( typeof rssOptions . stylesheet === 'string' ) {
Original file line number Diff line number Diff line change @@ -92,6 +92,23 @@ describe('rss', () => {
9292 chai . expect ( body ) . xml . to . equal ( validXmlWithXSLStylesheet ) ;
9393 } ) ;
9494
95+ it ( 'should preserve self-closing tags on `customData`' , async ( ) => {
96+ const customData =
97+ '<atom:link href="https://example.com/feed.xml" rel="self" type="application/rss+xml"/>' ;
98+ const { body } = await rss ( {
99+ title,
100+ description,
101+ items : [ ] ,
102+ site,
103+ xmlns : {
104+ atom : 'http://www.w3.org/2005/Atom' ,
105+ } ,
106+ customData,
107+ } ) ;
108+
109+ chai . expect ( body ) . to . contain ( customData ) ;
110+ } ) ;
111+
95112 it ( 'should filter out entries marked as `draft`' , async ( ) => {
96113 const { body } = await rss ( {
97114 title,
You can’t perform that action at this time.
0 commit comments