From 4ac66f20ea3ba525545b7f32bee2e25487e9dc20 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sat, 3 Feb 2024 16:46:25 -0500 Subject: [PATCH 1/4] fix: allow rss feeds to have an enclosure with length of 0 --- packages/astro-rss/src/schema.ts | 2 +- packages/astro-rss/test/rss.test.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/astro-rss/src/schema.ts b/packages/astro-rss/src/schema.ts index 79d2e5987636..1c2db762dcad 100644 --- a/packages/astro-rss/src/schema.ts +++ b/packages/astro-rss/src/schema.ts @@ -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(), diff --git a/packages/astro-rss/test/rss.test.js b/packages/astro-rss/test/rss.test.js index 833abf91c9b7..08a499f0a473 100644 --- a/packages/astro-rss/test/rss.test.js +++ b/packages/astro-rss/test/rss.test.js @@ -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 = awaitgetRssString({ + 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; + }); }); From 1bdc45d8bdc5332037f559c383bcb35a7c5692b8 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sat, 3 Feb 2024 16:50:17 -0500 Subject: [PATCH 2/4] chore: add changeset --- .changeset/tidy-spoons-suffer.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tidy-spoons-suffer.md diff --git a/.changeset/tidy-spoons-suffer.md b/.changeset/tidy-spoons-suffer.md new file mode 100644 index 000000000000..d0b8ff7e950b --- /dev/null +++ b/.changeset/tidy-spoons-suffer.md @@ -0,0 +1,5 @@ +--- +"@astrojs/rss": patch +--- + +Update validation to allow for enclosures to have a length of 0 From b76fbc44de7f3af43e457dda4e2ffb0eea3beb40 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sun, 4 Feb 2024 00:18:48 -0500 Subject: [PATCH 3/4] fix: typo on test --- packages/astro-rss/test/rss.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro-rss/test/rss.test.js b/packages/astro-rss/test/rss.test.js index 08a499f0a473..d32c420f1629 100644 --- a/packages/astro-rss/test/rss.test.js +++ b/packages/astro-rss/test/rss.test.js @@ -229,7 +229,7 @@ describe('getRssString', () => { }); it('should not fail when an enclosure has a length of 0', async () => { - const str = awaitgetRssString({ + const str = await getRssString({ title, description, items: [ From 67825d1a4875680e8c8949ba9b351c5482afe09b Mon Sep 17 00:00:00 2001 From: Marco Campos Date: Sun, 4 Feb 2024 11:18:45 -0500 Subject: [PATCH 4/4] fix: update changeset description Co-authored-by: Florian Lefebvre --- .changeset/tidy-spoons-suffer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tidy-spoons-suffer.md b/.changeset/tidy-spoons-suffer.md index d0b8ff7e950b..a4d27966957c 100644 --- a/.changeset/tidy-spoons-suffer.md +++ b/.changeset/tidy-spoons-suffer.md @@ -2,4 +2,4 @@ "@astrojs/rss": patch --- -Update validation to allow for enclosures to have a length of 0 +Allows `enclosure' to have a length of 0