Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No check for the type of 'page' and 'numItems' #5

Open
HunteRoi opened this issue Aug 29, 2019 · 0 comments
Open

No check for the type of 'page' and 'numItems' #5

HunteRoi opened this issue Aug 29, 2019 · 0 comments

Comments

@HunteRoi
Copy link

HunteRoi commented Aug 29, 2019

Intro

Hey there!

I just went through your lib and src folders and read your scripts. It looks like you don't check for the result of parseInput for the currentPage and the perPage variables. This will then make the library not work properly and could cause issues.

I know that the people using your package could simply check the values before they submit them to your library however I feel like it still needs to make its own place into here.

Steps to reproduce

Step 1

Create a JS file (let's call it index.js) and copy-paste the following code :

const paginate = require('paginate-array');
const array = [1, 2, 3, 4, 5, 6];
console.log(paginate(array, NaN));

or

const paginate = require('paginate-array');
const array = [1, 2, 3, 4, 5, 6];
console.log(paginate(array, 1, NaN));

Step 2

Type node index.js and observe the result

Results

Expected

Uncaught TypeError: page is not a number
or
Uncaught TypeError: numItems is not a number

Received

{ currentPage: NaN,
  perPage: 10,
  total: 6,
  totalPages: 1,
  data: [] 
}

or

{ currentPage: 1,
  perPage: NaN,
  total: 6,
  totalPages: NaN,
  data: [] 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant