Skip to content

Commit

Permalink
skip test for broken versions of express
Browse files Browse the repository at this point in the history
  • Loading branch information
tlhunter committed May 31, 2023
1 parent 0cf85b2 commit 2643dd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/datadog-plugin-express/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,16 @@ describe('Plugin', () => {
it('should not lose the current path when route handler preceeded by a longer middleware resource', done => {
const app = express()

app.use(/\/foo\/(bar|baz|bez)/, (req, res, next) => {
next()
})
try {
app.use(/\/foo\/(bar|baz|bez)/, (req, res, next) => {
next()
})
} catch (err) {
// eslint-disable-next-line no-console
console.log('This version of Express (>4.0 <4.6) has broken support for regex routing. Skipping this test.')
this.skip && this.skip() // mocha allows dynamic skipping, tap does not
return done()
}

app.get('/foo/bar', (req, res) => {
res.status(200).send('')
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-plugin-router/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ function isMoreSpecificThan (routeA, routeB) {
}

function routeIsRegex (route) {
// console.log('ROUTE', typeof route, route)
// return route instanceof RegExp
return route.startsWith('(/') && route.endsWith('/)')
}

Expand Down

0 comments on commit 2643dd3

Please sign in to comment.