mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
9f9d8b2fec
no issue - This started as an attempt to simplify the admin redirect code - I realised we were sometimes using utils.redirect301 and sometimes not - Decided to move this into utils.url as it's more relevant to URL generation - Unified usage of redirects in the codebase - Updated tests & ensured we have basic coverage - rename adminRedirect -> redirectToAdmin - Tweak method signature, fix channel edit redirects - Tests: Optimised test descriptions for url-redirects_spec.js - ensure caching works as expected
20 lines
618 B
JavaScript
20 lines
618 B
JavaScript
// Pretty URL redirects
|
|
//
|
|
// These are two pieces of middleware that handle ensuring that
|
|
// URLs get formatted correctly.
|
|
// Slashes ensures that we get trailing slashes
|
|
// Uncapitalise changes case to lowercase
|
|
// @TODO optimise this to reduce the number of redirects required to get to a pretty URL
|
|
// @TODO move this to being used by routers?
|
|
var slashes = require('connect-slashes'),
|
|
config = require('../config');
|
|
|
|
module.exports = [
|
|
slashes(true, {
|
|
headers: {
|
|
'Cache-Control': 'public, max-age=' + config.get('caching:301:maxAge')
|
|
}
|
|
}),
|
|
require('./uncapitalise')
|
|
];
|