diff --git a/.gitignore b/.gitignore index 4915027..65e3fd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -node_modules/ -dist/ -coverage/ -yarn-error.log +node_modules +dist +yarn-error.log \ No newline at end of file diff --git a/package.json b/package.json index 1457448..2271ec1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "random-bunny", - "version": "2.1.2", + "version": "2.1.1", "description": "Get a random subreddit image url", "license": "MIT", "author": "Vylpes", diff --git a/src/index.ts b/src/index.ts index 400567e..bdd157d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,8 +41,8 @@ export default async function randomBunny(subreddit: string, sortBy?: string): P return { IsSuccess: false, }; - } else { - random = Math.floor((Math.random() * (dataWithImages.length - 1)) + 0); // Between 0 and (size - 1) + } else if (dataWithImages.length > 1) { + random = Math.floor((Math.random() * dataWithImages.length - 1) + 0); // Between 0 and (size - 1) } const randomSelect = dataWithImages[random];