Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coupon-code

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coupon-code - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

test/badWords.js

32

coupon-code.js

@@ -24,3 +24,6 @@ // --------------------------------------------------------------------------------------------------------------------

// constants
var badWordsList = ('SHPX PHAG JNAX JNAT CVFF PBPX FUVG GJNG GVGF SNEG URYY ZHSS QVPX XABO ' +
'NEFR FUNT GBFF FYHG GHEQ FYNT PENC CBBC OHGG SRPX OBBO WVFZ WVMM CUNG')
.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);})
.split(' ');
var symbolsStr = '0123456789ABCDEFGHJKLMNPQRTUVWXY';

@@ -56,10 +59,13 @@ var symbolsArr = symbolsStr.split('');

// default to a random code
for( i = 0; i < opts.parts; i++ ) {
part = '';
for ( j = 0; j < opts.partLen - 1; j++ ) {
part += randomSymbol();
do {
parts.length = 0;
for( i = 0; i < opts.parts; i++ ) {
part = '';
for ( j = 0; j < opts.partLen - 1; j++ ) {
part += randomSymbol();
}
part = part + checkDigitAlg1(part, i+1);
parts.push(part);
}
part = part + checkDigitAlg1(part, i+1);
parts.push(part);
}
} while (!exports.checkForBadWords(parts.join('')))
}

@@ -70,2 +76,12 @@

module.exports.checkForBadWords = function(code) {
var i;
code = code.toUpperCase();
for( i = 0; i < badWordsList.length; i++ ) {
if (code.indexOf(badWordsList[i]) > -1)
return true;
}
return false;
};
module.exports.validate = function(code, opts) {

@@ -72,0 +88,0 @@ if ( !code ) {

{
"name": "coupon-code",
"description": "An implementation of Perl's Algorithm::CouponCode for NodeJS.",
"version": "0.3.0",
"version": "0.4.0",
"author": {

@@ -13,6 +13,6 @@ "name":"Andrew Chilton",

"devDependencies": {
"tape": "~2.3.0"
"tape": "~4.0.0"
},
"dependencies": {
"xtend": "~2.1.1"
"xtend": "~4.0.0"
},

@@ -19,0 +19,0 @@ "main": "coupon-code.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc