Skip to content

Commit

Permalink
fix: send correct MIME for rss file
Browse files Browse the repository at this point in the history
closes #144
  • Loading branch information
XieJiSS committed Nov 10, 2020
1 parent 571d235 commit dd10f2a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/middlewares/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mime = require('mime');
module.exports = function(app) {
const { config, route } = this;
const { args = {} } = this.env;
const { root } = config;
const { root, feed } = config;

if (args.s || args.static) return;

Expand Down Expand Up @@ -63,7 +63,17 @@ module.exports = function(app) {
return;
}

res.setHeader('Content-Type', extname ? mime.getType(extname) : 'application/octet-stream');
if (feed && feed.path === url) {
if (feed.type === 'atom') {
res.setHeader('Content-Type', 'application/atom+xml');
} else if (feed.type === 'rss') {
res.setHeader('Content-Type', 'application/rss+xml');
} else {
res.setHeader('Content-Type', extname ? mime.getType(extname) : 'application/octet-stream');
}
} else {
res.setHeader('Content-Type', extname ? mime.getType(extname) : 'application/octet-stream');
}

if (method === 'GET') {
data.pipe(res).on('error', next);
Expand Down

0 comments on commit dd10f2a

Please sign in to comment.