mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
7e408ae808
no issue - removed support for `/rss/:page/` URLs - removed `/rss/1/` -> `/rss/` redirect
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
const ParentRouter = require('./ParentRouter');
|
|
const urlUtils = require('../../../server/lib/url-utils');
|
|
|
|
const controllers = require('./controllers');
|
|
|
|
/**
|
|
* @description RSS Router, which should be used as a sub-router in other routes.
|
|
*
|
|
* "/rss" -> RSS Router
|
|
*/
|
|
class RSSRouter extends ParentRouter {
|
|
constructor() {
|
|
super('RSSRouter');
|
|
|
|
this.route = {value: '/rss/'};
|
|
this._registerRoutes();
|
|
}
|
|
|
|
/**
|
|
* @description Register all routes of this router.
|
|
* @private
|
|
*/
|
|
_registerRoutes() {
|
|
this.mountRoute(this.route.value, controllers.rss);
|
|
|
|
// REGISTER: redirect rule
|
|
this.mountRoute('/feed/', this._redirectFeedRequest.bind(this));
|
|
}
|
|
|
|
/**
|
|
* @description Simple controller function to redirect /rss to /feed
|
|
* @param {Object} req
|
|
* @param {Object}res
|
|
* @private
|
|
*/
|
|
_redirectFeedRequest(req, res) {
|
|
urlUtils
|
|
.redirect301(
|
|
res,
|
|
urlUtils.urlJoin(urlUtils.getSubdir(), req.baseUrl, this.route.value)
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = RSSRouter;
|