diff --git a/src/index.ts b/src/index.ts index b9ed5f9..cffb534 100644 --- a/src/index.ts +++ b/src/index.ts @@ -96,7 +96,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho let gallery: string[]; if (randomData.url.includes("/gallery")) { - const galleryImage = await ImageHelper.FetchImageFromRedditGallery(randomData.url); + const galleryImage = await ImageHelper.FetchImageFromRedditGallery(`https://reddit.com${randomData.permalink}`); if (!galleryImage) { return { diff --git a/tests/index.test.ts b/tests/index.test.ts index 8e49ffd..0814d7a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -202,7 +202,7 @@ describe('randomBunny', () => { expect(fetchMock).toHaveBeenCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledTimes(1); - expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledWith("https://i.redd.it/gallery/cr8xudsnkgua1"); + expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledWith("https://reddit.com/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/"); }); test("GIVEN data fetched is a gallery AND an image is not returned from the helper, EXPECT error", async () => {