@@ -35,6 +35,8 @@ const validXmlWithCustomDataResult = `<?xml version="1.0" encoding="UTF-8"?><rss
3535const validXmlWithStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.css"?><rss version="2.0"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link></channel></rss>` ;
3636// biome-ignore format: keep in one line
3737const validXmlWithXSLStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.xsl" type="text/xsl"?><rss version="2.0"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link></channel></rss>` ;
38+ // biome-ignore format: keep in one line
39+ const validXmlWithXSLTStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.xslt" type="text/xsl"?><rss version="2.0"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link></channel></rss>` ;
3840
3941function assertXmlDeepEqual ( a , b ) {
4042 const parsedA = parseXmlString ( a ) ;
@@ -161,9 +163,25 @@ describe('getRssString', () => {
161163 stylesheet : '/feedstylesheet.xsl' ,
162164 } ) ;
163165
166+ // xml2js doesn't parse processing instructions. Assert the type is present.
167+ assert . equal ( str . includes ( 'type="text/xsl"' ) , true ) ;
164168 assertXmlDeepEqual ( str , validXmlWithXSLStylesheet ) ;
165169 } ) ;
166170
171+ it ( 'should include xml-stylesheet instruction with xslt type when stylesheet is set to xslt file' , async ( ) => {
172+ const str = await getRssString ( {
173+ title,
174+ description,
175+ items : [ ] ,
176+ site,
177+ stylesheet : '/feedstylesheet.xslt' ,
178+ } ) ;
179+
180+ // xml2js doesn't parse processing instructions. Assert the type is present.
181+ assert . equal ( str . includes ( 'type="text/xsl"' ) , true ) ;
182+ assertXmlDeepEqual ( str , validXmlWithXSLTStylesheet ) ;
183+ } ) ;
184+
167185 it ( 'should preserve self-closing tags on `customData`' , async ( ) => {
168186 const customData =
169187 '<atom:link href="https://example.com/feed.xml" rel="self" type="application/rss+xml"/>' ;
0 commit comments