diff --git a/src/express-middleware.js b/src/express-middleware.js index a1ef3d4..7408fef 100644 --- a/src/express-middleware.js +++ b/src/express-middleware.js @@ -73,13 +73,6 @@ class ExpressMiddleware { } } - // nest.js - build request url pattern if exists - if (typeof req.params === 'object') { - Object.keys(req.params).forEach((paramName) => { - route = route.replace(req.params[paramName], ':' + paramName); - }); - } - // this condition will evaluate to true only in // express framework and no route was found for the request. if we log this metrics // we'll risk in a memory leak since the route is not a pattern but a hardcoded string. diff --git a/test/integration-tests/nest-js/middleware-test.spec.ts b/test/integration-tests/nest-js/middleware-test.spec.ts index 13b1f7b..244d452 100644 --- a/test/integration-tests/nest-js/middleware-test.spec.ts +++ b/test/integration-tests/nest-js/middleware-test.spec.ts @@ -61,6 +61,27 @@ describe('when using nest-js framework', () => { }); }); }); + + describe('route should be unaltered by user inputs (#114)', () => { + before(() => { + return request(server) + .get('/users/s/app-id/p') + .expect(200) + .expect({ + app_id: 'some_app_id' + }); + }); + + it('should add it to the histogram', () => { + return request(server) + .get('/metrics') + .expect(200) + .then((res) => { + expect(res.text).to.contain('method="GET",route="/users/:user_id/app-id/:app_id",code="200"'); + }); + }); + }); + describe('When calling a GET user/:user_id/app-id/:app_id with user_id and app_id as pattern and query params', () => { before(() => { return request(server)