拯救翻车的 API (#698)

This commit is contained in:
Henry Wang
2018-09-15 13:55:59 +08:00
committed by DIYgod
parent 29ffa930e5
commit 818e0cd077
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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;
};