From f2ec6a0405a7bf590db5da5b6ef86d609ccfa0fc Mon Sep 17 00:00:00 2001 From: jjeejj Date: Sat, 5 May 2018 10:21:04 +0800 Subject: [PATCH] fix middleware/utf8.js file bug --- middleware/utf8.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/utf8.js b/middleware/utf8.js index cca1a34a8..c513eb2da 100644 --- a/middleware/utf8.js +++ b/middleware/utf8.js @@ -2,5 +2,5 @@ // https://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string/1497928#1497928 module.exports = async (ctx, next) => { await next(); - ctx.body = ctx.body.replace(/[\x00-\x1F\x7F]/g, ''); + ctx.body = ctx.body?ctx.body.replace(/[\x00-\x1F\x7F]/g, ''):ctx.body; };