0
Fork 0
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:
Marco Campos 2024-02-04 14:42:26 -05:00 committed by GitHub
parent 57ab98f531
commit 8b8f26fdf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"@astrojs/rss": patch
---
Allows `enclosure' to have a length of 0

View file

@ -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(),

View file

@ -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;
});
});