diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bcb88d4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 20 + ignore: + - dependency-name: open + versions: + - 8.0.1 + - 8.0.2 + - 8.0.3 + - 8.0.4 + - 8.0.5 + - 8.0.6 + - dependency-name: sinon + versions: + - 10.0.0 diff --git a/lib/middlewares/route.js b/lib/middlewares/route.js index b3f9d2d..c3c8d2c 100644 --- a/lib/middlewares/route.js +++ b/lib/middlewares/route.js @@ -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; @@ -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); diff --git a/package.json b/package.json index 0df6724..9ae8c89 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "connect": "^3.7.0", "mime": "^2.4.3", "morgan": "^1.9.1", - "open": "^7.0.0", + "open": "^8.0.9", "serve-static": "^1.14.1" }, "devDependencies": { @@ -47,7 +47,7 @@ "hexo-util": "^2.1.0", "mocha": "^8.0.1", "nyc": "^15.0.0", - "sinon": "^9.0.2", + "sinon": "^10.0.1", "supertest": "^6.1.3", "uuid": "^8.0.0" },