Skip to content

Commit b81d9d8

Browse files
wantsuiwconti27
andauthored
Prevent errors in Express 5.x applications (#4872)
* Fix integration by preventing unsafe access to properties. --------- Co-authored-by: William Conti <william.conti@datadoghq.com> Co-authored-by: William Conti <58711692+wconti27@users.noreply.github.com>
1 parent 0a44e6e commit b81d9d8

File tree

1 file changed

+2
-3
lines changed
  • packages/datadog-instrumentations/src

1 file changed

+2
-3
lines changed

packages/datadog-instrumentations/src/router.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ function createWrapRouterMethod (name) {
112112
path: pattern instanceof RegExp ? `(${pattern})` : pattern,
113113
test: layer => {
114114
const matchers = layerMatchers.get(layer)
115-
116115
return !isFastStar(layer, matchers) &&
117116
!isFastSlash(layer, matchers) &&
118117
cachedPathToRegExp(pattern).test(layer.path)
@@ -121,15 +120,15 @@ function createWrapRouterMethod (name) {
121120
}
122121

123122
function isFastStar (layer, matchers) {
124-
if (layer.regexp.fast_star !== undefined) {
123+
if (layer.regexp?.fast_star !== undefined) {
125124
return layer.regexp.fast_star
126125
}
127126

128127
return matchers.some(matcher => matcher.path === '*')
129128
}
130129

131130
function isFastSlash (layer, matchers) {
132-
if (layer.regexp.fast_slash !== undefined) {
131+
if (layer.regexp?.fast_slash !== undefined) {
133132
return layer.regexp.fast_slash
134133
}
135134

0 commit comments

Comments
 (0)