Add basepath when redirecting from a trailling slash (#9033)

Backports PR #8966

**Commit 1:**
Add basepath when redirecting from a trailling slash

* Original sha: 442bcb9044
* Authored by Jonathan Budzenski <jon@jbudz.me> on 2016-11-04T13:33:24Z
This commit is contained in:
jasper 2016-11-10 15:06:44 -05:00 committed by Jonathan Budzenski
parent 4a76abcca7
commit 321e7e53f2

View file

@ -103,10 +103,10 @@ module.exports = async function (kbnServer, server, config) {
if (path === '/' || path.charAt(path.length - 1) !== '/') {
return reply(Boom.notFound());
}
const pathPrefix = config.get('server.basePath') ? `${config.get('server.basePath')}/` : '';
return reply.redirect(format({
search: req.url.search,
pathname: path.slice(0, -1),
pathname: pathPrefix + path.slice(0, -1),
}))
.permanent(true);
}