mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
91ca4a43e5
closes #1757 and #1773 - switches routes.frontend for posts and pages to use a regex with two capturing groups. This removes the need to dynamically remove an express route at a later point, leaving the decision making to frontend controller. - added unit tests for all routing conditions that can arise for posts and pages. - updated functional tests to also test for same thing in unit tests - removes old code from server/api/index that used to fix this issue, but is no longer needed - removed some un-needed require statements in routes/admin
19 lines
No EOL
785 B
JavaScript
19 lines
No EOL
785 B
JavaScript
var frontend = require('../controllers/frontend');
|
|
|
|
module.exports = function (server) {
|
|
/*jslint regexp: true */
|
|
|
|
// ### Frontend routes
|
|
/* TODO: dynamic routing, homepage generator, filters ETC ETC */
|
|
server.get('/rss/', frontend.rss);
|
|
server.get('/rss/:page/', frontend.rss);
|
|
server.get('/page/:page/', frontend.homepage);
|
|
// Only capture the :slug part of the URL
|
|
// This regex will always have two capturing groups,
|
|
// one for date, and one for the slug.
|
|
// Examples:
|
|
// Given `/plain-slug/` the req.params would be ['', 'plain-slug']
|
|
// Given `/2012/12/24/plain-slug/` the req.params would be ['2012/12/24', 'plain-slug']
|
|
server.get(/^\/([0-9\/]*)([^\/.]*)\/$/, frontend.single);
|
|
server.get('/', frontend.homepage);
|
|
}; |