credit-card-regex
Advanced tools
Comparing version 1.2.0 to 1.2.1
103
index.js
'use strict'; | ||
var americanExpress = '(?:3[47][0-9]{13})'; | ||
var dinersClub = '(?:3(?:0[0-5]|[68][0-9])[0-9]{11})'; | ||
var discover = '(?:6(?:011|5[0-9]{2})(?:[0-9]{12}))'; | ||
var jcb = '(?:(?:2131|1800|35\\d{3})\\d{11})'; | ||
var maestro = '(?:(?:5[0678]\\d\\d|6304|6390|67\\d\\d)\\d{8,15})'; | ||
var mastercard = '(?:5[1-5][0-9]{14})'; | ||
var visa = '(?:4[0-9]{12})(?:[0-9]{3})?'; | ||
var streamCombiner = require('stream-combiner'); | ||
/** | ||
* Regular expression for matching credit card numbers | ||
* | ||
* @api public | ||
*/ | ||
function dest(paths) { | ||
var arr = []; | ||
module.exports = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + [ | ||
americanExpress, | ||
dinersClub, | ||
discover, | ||
jcb, | ||
maestro, | ||
mastercard, | ||
visa | ||
].join('|') + '\\1', 'g'); | ||
}; | ||
arr = paths.map(function (path) { | ||
return gulp.dest(path); | ||
}); | ||
/** | ||
* American Express | ||
* | ||
* @api public | ||
*/ | ||
return streamCombiner(arr); | ||
} | ||
module.exports.americanExpress = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + americanExpress + '\\1', 'g'); | ||
}; | ||
/** | ||
* Diners Club | ||
* | ||
* @api public | ||
*/ | ||
module.exports.dinersClub = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + dinersClub + '\\1', 'g'); | ||
}; | ||
/** | ||
* Discover | ||
* | ||
* @api public | ||
*/ | ||
module.exports.discover = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + discover + '\\1', 'g'); | ||
}; | ||
/** | ||
* JCB | ||
* | ||
* @api public | ||
*/ | ||
module.exports.jcb = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + jcb + '\\1', 'g'); | ||
}; | ||
/** | ||
* Maestro | ||
* | ||
* @api public | ||
*/ | ||
module.exports.maestro = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + maestro + '\\1', 'g'); | ||
}; | ||
/** | ||
* Mastercard | ||
* | ||
* @api public | ||
*/ | ||
module.exports.mastercard = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + mastercard + '\\1', 'g'); | ||
}; | ||
/** | ||
* VISA | ||
* | ||
* @api public | ||
*/ | ||
module.exports.visa = function () { | ||
return new RegExp('(?:^|\\s)?(["\'])?' + visa + '\\1', 'g'); | ||
}; | ||
gulp.task('default', function () { | ||
gulp.src('src/**/*') | ||
.pipe(dest(['dest', 'build'])); | ||
}); |
{ | ||
"name": "credit-card-regex", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Regular expression for matching credit card numbers", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test/test.js" | ||
}, | ||
@@ -23,6 +23,13 @@ "files": [ | ||
"keywords": [ | ||
"americanexpress", | ||
"creditcard", | ||
"dinersclub", | ||
"discover", | ||
"jcb", | ||
"maestro", | ||
"mastercard", | ||
"number", | ||
"regex", | ||
"string" | ||
"string", | ||
"visa" | ||
], | ||
@@ -29,0 +36,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58
3269
13