diff --git a/api_router.js b/api_router.js index 004dca765..2b4cd8d8f 100644 --- a/api_router.js +++ b/api_router.js @@ -12,7 +12,7 @@ router.get('/routes/:name?', (ctx) => { const path = i.path; const top = path.split('/')[1]; - if (ctx.params.name === undefined || top === ctx.params.name) { + if (!ctx.params.name || top === ctx.params.name) { if (result[top]) { result[top].routes.push(path); } else { diff --git a/middleware/utf8.js b/middleware/utf8.js index 4c90349d0..b7ee6291f 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 ? ctx.body.replace(/[\x00-\x1F\x7F]/g, '') : ctx.body; + ctx.body = typeof ctx.body !== 'object' ? ctx.body.replace(/[\x00-\x1F\x7F]/g, '') : ctx.body; };