From 6131c817860af1b72d432fd7cf939307e21b171f Mon Sep 17 00:00:00 2001 From: kscript <1258@live.cn> Date: Thu, 14 Feb 2019 14:51:29 +0800 Subject: [PATCH] The project root directory is missing --- lib/generator.js | 2 +- test/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/generator.js b/lib/generator.js index 8af023c..510c244 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -32,7 +32,7 @@ module.exports = function(locals) { if (feedConfig.limit) posts = posts.limit(feedConfig.limit); var url = config.url; - if (url[url.length - 1] !== '/') url += '/'; + url = url.slice(0, -1) + [url.slice(-1), '/', config.root, '/'].join('').replace(/\/+/g, '/'); var icon; if (feedConfig.icon) icon = url + feedConfig.icon; diff --git a/test/index.js b/test/index.js index 344963b..a562cb1 100644 --- a/test/index.js +++ b/test/index.js @@ -155,10 +155,10 @@ describe('Feed generator', function() { var GOOD = 'http://localhost/blog/'; - checkURL('http://localhost/blog', '/blog/', GOOD); - checkURL('http://localhost/blog', '/blog', GOOD); - checkURL('http://localhost/blog/', '/blog/', GOOD); - checkURL('http://localhost/blog/', '/blog', GOOD); + checkURL('http://localhost', '/blog/', GOOD); + checkURL('http://localhost', '/blog', GOOD); + checkURL('http://localhost/', '/blog/', GOOD); + checkURL('http://localhost/', '/blog', GOOD); checkURL('http://localhost/b/l/o/g', '/', 'http://localhost/b/l/o/g/');