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