File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
datadog-plugin-express/test
datadog-plugin-router/src Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,42 @@ describe('Plugin', () => {
741741 } )
742742 } )
743743
744+ it ( 'should work with regex having flags' , done => {
745+ const app = express ( )
746+
747+ try {
748+ app . use ( / \/ f o o \/ ( b a r | b a z | b e z ) / i, ( req , res , next ) => {
749+ next ( )
750+ } )
751+ } catch ( err ) {
752+ // eslint-disable-next-line no-console
753+ console . log ( 'This version of Express (>4.0 <4.6) has broken support for regex routing. Skipping this test.' )
754+ this . skip && this . skip ( ) // mocha allows dynamic skipping, tap does not
755+ return done ( )
756+ }
757+
758+ app . get ( '/foo/bar' , ( req , res ) => {
759+ res . status ( 200 ) . send ( '' )
760+ } )
761+
762+ getPort ( ) . then ( port => {
763+ agent
764+ . use ( traces => {
765+ const spans = sort ( traces [ 0 ] )
766+
767+ expect ( spans [ 0 ] ) . to . have . property ( 'resource' , 'GET /foo/bar' )
768+ } )
769+ . then ( done )
770+ . catch ( done )
771+
772+ appListener = app . listen ( port , 'localhost' , ( ) => {
773+ axios
774+ . get ( `http://localhost:${ port } /foo/bar` )
775+ . catch ( done )
776+ } )
777+ } )
778+ } )
779+
744780 it ( 'long regex child of string router should not steal path' , done => {
745781 const app = express ( )
746782 const router = express . Router ( )
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ function isMoreSpecificThan (routeA, routeB) {
156156}
157157
158158function routeIsRegex ( route ) {
159- return route . includes ( '(/' ) && route . includes ( '/)' )
159+ return route . includes ( '(/' )
160160}
161161
162162module . exports = RouterPlugin
You can’t perform that action at this time.
0 commit comments