Skip to content

Commit

Permalink
use named function
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasShabi committed Dec 6, 2024
1 parent eff2153 commit d764b89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/datadog-instrumentations/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ addHook({
function wrapParam (original) {
return function wrappedProcessParams () {
arguments[1] = shimmer.wrapFunction(arguments[1], (originalFn) => {
return (...args) => {
const [req, res] = args

return function wrappedFn (req, res) {
if (routerParamStartCh.hasSubscribers && Object.keys(req.params).length && !visitedParams.has(req.params)) {
visitedParams.add(req.params)

Expand All @@ -259,7 +257,7 @@ function wrapParam (original) {
if (abortController.signal.aborted) return
}

return originalFn.apply(this, args)
return originalFn.apply(this, arguments)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,21 @@ describe('Path params sourcing with express', () => {
})

it('should taint path param on router.params callback with custom implementation', function (done) {
if (!semver.satisfies(expressVersion, '4')) {
this.skip()
}
const app = express()

app.use('/:parameter1/:parameter2', (req, res) => {
res.status(200).send()
})

app.param(['parameter1', 'parameter2'], checkParamIsTaintedAndNext)
app.param((param, option) => {
return checkParamIsTaintedAndNext
})

app.param('parameter1')
app.param('parameter2')

appListener = app.listen(0, 'localhost', () => {
const port = appListener.address().port
Expand Down

0 comments on commit d764b89

Please sign in to comment.