mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: Provide radix argument to parseInt (#8281)
* DEV: Provide radix 10 argument to parseInt * DEV: Provide radix 16 argument to parseInt * DEV: Remove unnecessary parseInt calls * Fix year formatting parseInt was used here to convert decimals to ints
This commit is contained in:
@ -436,25 +436,25 @@ export default function() {
|
||||
|
||||
this.get("/t/:topic_id/posts.json", request => {
|
||||
const postIds = request.queryParams.post_ids;
|
||||
const postNumber = parseInt(request.queryParams.post_number);
|
||||
const postNumber = parseInt(request.queryParams.post_number, 10);
|
||||
let posts;
|
||||
|
||||
if (postIds) {
|
||||
posts = postIds.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "true") {
|
||||
posts = _.range(postNumber + 1, postNumber + 6).map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "false") {
|
||||
posts = _.range(postNumber - 5, postNumber)
|
||||
.reverse()
|
||||
.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user