Skip to content

Commit ca04cf0

Browse files
committed
Tweaks
1 parent f44a0ba commit ca04cf0

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
32
var americanExpress = '(?:3[47][0-9]{13})';
43
var dinersClub = '(?:3(?:0[0-5]|[68][0-9])[0-9]{11})';
54
var discover = '(?:6(?:011|5[0-9]{2})(?:[0-9]{12}))';
@@ -12,7 +11,7 @@ function generate(pattern) {
1211
return function (opts) {
1312
opts = opts || {};
1413
return opts.exact ? new RegExp('(?:^' + pattern + '$)') :
15-
new RegExp('(?:^|\\s)?(["\'])?' + pattern + '\\1', 'g');
14+
new RegExp('(["\'])?' + pattern + '\\1', 'g');
1615
};
1716
}
1817

test/test.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
32
var test = require('ava');
43
var creditCardRegex = require('../');
54

@@ -15,12 +14,7 @@ test('match credit card numbers', function (t) {
1514
);
1615

1716
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);
2418
});
2519

2620
t.end();

0 commit comments

Comments
 (0)