diff --git a/src/routes/standard_pages.js b/src/routes/standard_pages.js index b74bbc4..8712415 100644 --- a/src/routes/standard_pages.js +++ b/src/routes/standard_pages.js @@ -111,12 +111,19 @@ router.get("/tag/:tag", (req,res) => { // Comments router.get("/comment/:postID-:commentID", (req,res) => { - const commentID = req.params.commentID; - const postID = req.params.postID; + const commentID = parseInt(req.params.commentID); + const postID = parseInt(req.params.postID); let posts_comments = data.getdata('comments', postID) - let comment = posts_comments[commentID] - if (comment == -1) { + let comment = 1 + // For loop to find the comment with matching ID + posts_comments.forEach((current_comment, index) => { + if (current_comment.id == commentID) { + comment = posts_comments[index] + } + }) + // If comment doesn't exist, show error + if (comment == 1 || posts_comments == 1) { // Comment of this ID was not found res.render("partials/message", { config, message: locale.comment_doesnt_exist, diff --git a/views/pages/timeline.ejs b/views/pages/timeline.ejs index 30b9922..83fc061 100644 --- a/views/pages/timeline.ejs +++ b/views/pages/timeline.ejs @@ -22,6 +22,13 @@ <% } %> <% } %> +