-
Notifications
You must be signed in to change notification settings - Fork 0
Add Parameter Check for Negative Page Number #1503
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖
|
Page | Size (compressed) |
---|---|
global |
353.52 KB (🟡 +4 B) |
Details
The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.
Any third party scripts you have added directly to your app using the <script>
tag are not accounted for in this analysis
If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR 👍 but deploy_block ☁️ on minor suggestion.
Also is Add
supposed to be the full title of this PR?
p: | ||
typeof p === 'string' && parseInt(p) >= 0 | ||
? parseInt(p) | ||
: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code it seems that p
can by of type any
.
However, parseInt()
will return NaN
if it can't parse the integer https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/parseint
So we can extract the parsing to a line above and then simply check the negative value in this line. This will make the line less bloated and not have to run parseInt
twice.
So something like
const pageParam = parseInt(p)
return {
q: String(q || ''),
p: pageParam >= 0 ? pageParam : undefined
un_deploy_block ⚡ spoke with @TomiFixit and |
QA 🟢 Using a negative page number with the Testing Procedure:
|
Closes #1492
QA
If the page number is invalid (<0), the parameter is ignored.