diff --git a/index.js b/index.js index eb0793e..dff0403 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,6 @@ module.exports = async function (fastify, opts) { function reply (request, reply) { var dest = request.req.url.replace(this.basePath, '') - reply.from(dest) + reply.from(dest || '/') } } diff --git a/test.js b/test.js index 245f786..211a59e 100644 --- a/test.js +++ b/test.js @@ -68,6 +68,9 @@ async function run () { const resultRoot = await got(`http://localhost:${server.server.address().port}/my-prefix/`) t.equal(resultRoot.body, 'this is root') + const withoutSlash = await got(`http://localhost:${server.server.address().port}/my-prefix`) + t.equal(withoutSlash.body, 'this is root') + const resultA = await got(`http://localhost:${server.server.address().port}/my-prefix/a`) t.equal(resultA.body, 'this is a') })