diff --git a/lib/middleware/template.js b/lib/middleware/template.js index 69ae580e7d..436223c44d 100644 --- a/lib/middleware/template.js +++ b/lib/middleware/template.js @@ -1,16 +1,20 @@ const art = require('art-template'); const path = require('path'); const config = require('@/config').value; -const typeRegrx = /\.(atom|rss)$/; -const unsupportedRegrx = /\.json$/; +const typeRegex = /\.(atom|rss)$/; +const unsupportedRegex = /\.json$/; module.exports = async (ctx, next) => { - if (ctx.request.path.match(unsupportedRegrx)) { + if (ctx.request.path.match(unsupportedRegex)) { throw Error('JSON output had been removed, see: https://github.com/DIYgod/RSSHub/issues/1114'); } - ctx.state.type = ctx.request.path.match(typeRegrx) || ['', '']; - ctx.request.path = ctx.request.path.replace(typeRegrx, ''); + if (ctx.headers['user-agent'].includes('Reeder')) { + ctx.request.path = ctx.request.path.replace(/.com$/, ''); + } + + ctx.state.type = ctx.request.path.match(typeRegex) || ['', '']; + ctx.request.path = ctx.request.path.replace(typeRegex, ''); await next();