File tree Expand file tree Collapse file tree 2 files changed +2
-9
lines changed Expand file tree Collapse file tree 2 files changed +2
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
-
3
2
var americanExpress = '(?:3[47][0-9]{13})' ;
4
3
var dinersClub = '(?:3(?:0[0-5]|[68][0-9])[0-9]{11})' ;
5
4
var discover = '(?:6(?:011|5[0-9]{2})(?:[0-9]{12}))' ;
@@ -12,7 +11,7 @@ function generate(pattern) {
12
11
return function ( opts ) {
13
12
opts = opts || { } ;
14
13
return opts . exact ? new RegExp ( '(?:^' + pattern + '$)' ) :
15
- new RegExp ( '(?:^|\\s)?( ["\'])?' + pattern + '\\1' , 'g' ) ;
14
+ new RegExp ( '(["\'])?' + pattern + '\\1' , 'g' ) ;
16
15
} ;
17
16
}
18
17
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
-
3
2
var test = require ( 'ava' ) ;
4
3
var creditCardRegex = require ( '../' ) ;
5
4
@@ -15,12 +14,7 @@ test('match credit card numbers', function (t) {
15
14
) ;
16
15
17
16
fixtures . forEach ( function ( el ) {
18
- if ( ! creditCardRegex ( ) . exec ( el ) ) {
19
- t . assert ( false , el ) ;
20
- return ;
21
- }
22
-
23
- t . assert ( creditCardRegex ( ) . exec ( el ) [ 0 ] === el , el ) ;
17
+ t . assert ( creditCardRegex ( { exact : true } ) . test ( el ) , el ) ;
24
18
} ) ;
25
19
26
20
t . end ( ) ;
You can’t perform that action at this time.
0 commit comments