mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
FIX: allow rss feeds to have an enclosure with length of 0 (#9967)
* fix: allow rss feeds to have an enclosure with length of 0 * chore: add changeset * fix: typo on test * fix: update changeset description Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
This commit is contained in:
parent
57ab98f531
commit
8b8f26fdf2
3 changed files with 29 additions and 1 deletions
5
.changeset/tidy-spoons-suffer.md
Normal file
5
.changeset/tidy-spoons-suffer.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/rss": patch
|
||||
---
|
||||
|
||||
Allows `enclosure' to have a length of 0
|
|
@ -16,7 +16,7 @@ export const rssSchema = z.object({
|
|||
enclosure: z
|
||||
.object({
|
||||
url: z.string(),
|
||||
length: z.number().positive().int().finite(),
|
||||
length: z.number().nonnegative().int().finite(),
|
||||
type: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
|
|
|
@ -227,4 +227,27 @@ describe('getRssString', () => {
|
|||
}
|
||||
chai.expect(error).to.be.null;
|
||||
});
|
||||
|
||||
it('should not fail when an enclosure has a length of 0', async () => {
|
||||
const str = await getRssString({
|
||||
title,
|
||||
description,
|
||||
items: [
|
||||
{
|
||||
title: 'Title',
|
||||
pubDate: new Date().toISOString(),
|
||||
description: 'Description',
|
||||
link: '/link',
|
||||
enclosure: {
|
||||
url: '/enclosure',
|
||||
length: 0,
|
||||
type: 'audio/mpeg',
|
||||
},
|
||||
},
|
||||
],
|
||||
site,
|
||||
});
|
||||
|
||||
chai.expect(str).to.not.throw;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue