File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ var shouldHitHandle = utils.shouldHitHandle
14
14
var shouldNotHaveBody = utils . shouldNotHaveBody
15
15
var shouldNotHitHandle = utils . shouldNotHitHandle
16
16
17
- // Named capturing groups are available from Node `10.0.0` and up
18
- var describeCaptureGroups = runningOnNodeMajorVersionGreaterOrEqualThan ( 10 ) ? describe : describe . skip
17
+ var describeNamedCaptureGroups = supportsRegExp ( '(?<foo>.)' ) ? describe : describe . skip
19
18
var describePromises = global . Promise ? describe : describe . skip
20
19
21
20
describe ( 'Router' , function ( ) {
@@ -1021,7 +1020,7 @@ describe('Router', function () {
1021
1020
} )
1022
1021
} )
1023
1022
1024
- describeCaptureGroups ( 'using "(?<name>)"' , function ( ) {
1023
+ describeNamedCaptureGroups ( 'using "(?<name>)"' , function ( ) {
1025
1024
it ( 'should allow defining capturing groups using regexps' , function ( done ) {
1026
1025
var cb = after ( 3 , done )
1027
1026
var router = new Router ( )
@@ -1095,6 +1094,10 @@ function sendParams (req, res) {
1095
1094
res . end ( JSON . stringify ( req . params ) )
1096
1095
}
1097
1096
1098
- function runningOnNodeMajorVersionGreaterOrEqualThan ( version ) {
1099
- return Number ( process . versions . node . split ( '.' ) [ 0 ] ) >= Number ( version )
1097
+ function supportsRegExp ( source ) {
1098
+ try {
1099
+ return RegExp ( source ) . source !== ''
1100
+ } catch ( e ) {
1101
+ return false
1102
+ }
1100
1103
}
You can’t perform that action at this time.
0 commit comments