diff --git a/lib/middleware/template.tsx b/lib/middleware/template.tsx index 65dbfa65f3cec1..e91084ed3957c8 100644 --- a/lib/middleware/template.tsx +++ b/lib/middleware/template.tsx @@ -94,18 +94,22 @@ const middleware: MiddlewareHandler = async (ctx, next) => { return ctx.json(result); } - // retain .ums for backward compatibility - if (outputType === 'ums' || outputType === 'rss3') { - return ctx.json(rss3(result)); - } else if (outputType === 'json') { - ctx.header('Content-Type', 'application/feed+json; charset=UTF-8'); - return ctx.body(json(result)); - } else if (ctx.get('no-content')) { + if (ctx.get('no-content')) { return ctx.body(null); - } else if (outputType === 'atom') { - return ctx.render(); } else { - return ctx.render(); + // retain .ums for backward compatibility + switch (outputType) { + case 'ums': + case 'rss3': + return ctx.json(rss3(result)); + case 'json': + ctx.header('Content-Type', 'application/feed+json; charset=UTF-8'); + return ctx.body(json(result)); + case 'atom': + return ctx.render(); + default: + return ctx.render(); + } } };