mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
move / redirection to catch-all route so that routes can use trailing slashes
This commit is contained in:
parent
f51ec29837
commit
615f4c972a
1 changed files with 17 additions and 13 deletions
|
@ -9,19 +9,6 @@ module.exports = function (kbnServer, server, config) {
|
|||
port: config.get('kibana.server.port')
|
||||
});
|
||||
|
||||
server.ext('onRequest', function (req, reply) {
|
||||
var path = req.path;
|
||||
if (path === '/' || path.charAt(path.length - 1) !== '/') {
|
||||
return reply.continue();
|
||||
}
|
||||
|
||||
return reply.redirect(format({
|
||||
search: req.url.search,
|
||||
pathname: path.slice(0, -1),
|
||||
}))
|
||||
.permanent(true);
|
||||
});
|
||||
|
||||
// provide a simple way to expose static directories
|
||||
server.decorate('server', 'exposeStaticDir', function (routePath, dirPath) {
|
||||
this.route({
|
||||
|
@ -70,4 +57,21 @@ module.exports = function (kbnServer, server, config) {
|
|||
reply.redirect(config.get('kibana.defaultRoute'));
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{p*}',
|
||||
handler: function (req, reply) {
|
||||
var path = req.path;
|
||||
if (path === '/' || path.charAt(path.length - 1) !== '/') {
|
||||
return reply(Boom.notFound());
|
||||
}
|
||||
|
||||
return reply.redirect(format({
|
||||
search: req.url.search,
|
||||
pathname: path.slice(0, -1),
|
||||
}))
|
||||
.permanent(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue