diff --git a/index.js b/index.js index 5309e27b..5f9dd358 100644 --- a/index.js +++ b/index.js @@ -84,9 +84,7 @@ const fastifyAutoload = async function autoload (fastify, options) { registerAllPlugins(app, pluginFiles, true) } - fastify.register(composedPlugin, { - prefix: options.options?.prefix ?? replaceRouteParamPattern(prefix) - }) + fastify.register(composedPlugin, { prefix: options.options?.prefix ?? prefix }) } } diff --git a/test/issues/374/routes/entity/.autohooks.js b/test/issues/374/routes/entity/.autohooks.js deleted file mode 100644 index 951e9583..00000000 --- a/test/issues/374/routes/entity/.autohooks.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' - -module.exports = async function (app, opts) { - app.addHook('onRequest', async (req, reply) => { - req.hooked = req.hooked || [] - req.hooked.push('root') - }) -} diff --git a/test/issues/374/routes/entity/_entity/index.js b/test/issues/374/routes/entity/_entity/index.js deleted file mode 100644 index c6d63048..00000000 --- a/test/issues/374/routes/entity/_entity/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -module.exports = async function (app, opts, next) { - app.get('/', async function (req, reply) { - reply.status(200).send({ path: req.url, hooked: req.hooked, params: req.params }) - }) -} diff --git a/test/issues/374/routes/entity/index.js b/test/issues/374/routes/entity/index.js deleted file mode 100644 index 0b14399b..00000000 --- a/test/issues/374/routes/entity/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -module.exports = async function (app, opts, next) { - app.get('/', async function (req, reply) { - reply.status(200).send({ path: req.url, hooked: req.hooked }) - }) -} diff --git a/test/issues/374/routes/index.js b/test/issues/374/routes/index.js deleted file mode 100644 index 51a699b4..00000000 --- a/test/issues/374/routes/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -module.exports = async function (app, opts, next) { - app.get('/', async function (req, reply) { - reply.status(200).send({ path: req.url }) - }) -} diff --git a/test/issues/374/test.js b/test/issues/374/test.js deleted file mode 100644 index 284d6403..00000000 --- a/test/issues/374/test.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict' - -const t = require('tap') -const path = require('node:path') -const Fastify = require('fastify') -const autoLoad = require('../../../') - -t.plan(10) - -const app = Fastify() - -app.register(autoLoad, { - dir: path.join(__dirname, 'routes'), - autoHooks: true, - cascadeHooks: true -}) - -app.ready(function (err) { - t.error(err) - - app.inject({ - url: '/' - }, function (err, res) { - t.error(err) - t.equal(res.statusCode, 200) - t.same(res.json(), { path: '/' }) - }) - - app.inject({ - url: '/entity' - }, function (err, res) { - t.error(err) - t.equal(res.statusCode, 200) - t.same(res.json(), { path: '/entity', hooked: ['root'] }) - }) - - app.inject({ - url: '/entity/1' - }, function (err, res) { - t.error(err) - t.equal(res.statusCode, 200) - t.same(res.json(), { path: '/entity/1', hooked: ['root'], params: { entity: 1 } }) - }) -})