From f32c5a3f41b9208c6a181ed92060d8ffc2eef509 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Sun, 6 Jun 2021 00:22:58 -0400 Subject: [PATCH] handle blank post body --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d5ea115..90987b2 100644 --- a/index.js +++ b/index.js @@ -103,9 +103,10 @@ function diff(current, checked) { app.post("/updates/:project(\\w+)", (req, res) => { let project_id = req.params['project']; - const body = req.body.replace(/\r/, ""); + const body = req.body || ""; + let adjustedBody = body.replace(/\r/, ""); let indexes = get_indexes(project_id); - let difference = diff(indexes, body); + let difference = diff(indexes, adjustedBody); if (difference.length > 0) { res.send(difference);