Comparing version 4.2.0 to 4.2.1
@@ -11,3 +11,3 @@ /*! | ||
* @module ibantools | ||
* @version 4.2.0 | ||
* @version 4.2.1 | ||
* @license MPL-2.0 | ||
@@ -619,30 +619,20 @@ * @preferred | ||
var checkFinlandBBAN = function (bban) { | ||
var weightsMethod1 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]; | ||
var weightsMethod2 = [0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 1, 3, 7]; | ||
var weights = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]; | ||
var controlDigit = parseInt(bban.charAt(13), 10); | ||
var toCheck = bban.substring(0, 13); | ||
var sum = 0; | ||
if (toCheck.startsWith('88')) { | ||
for (var index = 0; index < toCheck.length; index++) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weightsMethod2[index]; | ||
for (var index = 0; index < toCheck.length; index++) { | ||
if (weights[index] === 1) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weights[index]; | ||
} | ||
var remainder = sum % 10; | ||
return controlDigit === (remainder === 0 ? 0 : 10 - remainder); | ||
} | ||
else { | ||
for (var index = 0; index < toCheck.length; index++) { | ||
if (weightsMethod1[index] === 1) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weightsMethod1[index]; | ||
} | ||
else { | ||
var value = parseInt(toCheck.charAt(index), 10) * weightsMethod1[index]; | ||
sum += Math.floor(value / 10) + (value % 10); | ||
} | ||
else { | ||
var value = parseInt(toCheck.charAt(index), 10) * weights[index]; | ||
sum += Math.floor(value / 10) + (value % 10); | ||
} | ||
var extraSum = sum + controlDigit; | ||
var multiDigit = Math.floor(extraSum / 10); | ||
var result = multiDigit * 10; | ||
var remainder = result - sum; | ||
return remainder === controlDigit; | ||
} | ||
var extraSum = sum + controlDigit; | ||
var multiDigit = Math.floor(extraSum / 10); | ||
var result = multiDigit * 10; | ||
var remainder = result - sum; | ||
return remainder === controlDigit; | ||
}; | ||
@@ -649,0 +639,0 @@ /** |
@@ -11,3 +11,3 @@ /*! | ||
* @module ibantools | ||
* @version 4.2.0 | ||
* @version 4.2.1 | ||
* @license MPL-2.0 | ||
@@ -605,30 +605,20 @@ * @preferred | ||
var checkFinlandBBAN = function (bban) { | ||
var weightsMethod1 = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]; | ||
var weightsMethod2 = [0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 1, 3, 7]; | ||
var weights = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]; | ||
var controlDigit = parseInt(bban.charAt(13), 10); | ||
var toCheck = bban.substring(0, 13); | ||
var sum = 0; | ||
if (toCheck.startsWith('88')) { | ||
for (var index = 0; index < toCheck.length; index++) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weightsMethod2[index]; | ||
for (var index = 0; index < toCheck.length; index++) { | ||
if (weights[index] === 1) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weights[index]; | ||
} | ||
var remainder = sum % 10; | ||
return controlDigit === (remainder === 0 ? 0 : 10 - remainder); | ||
} | ||
else { | ||
for (var index = 0; index < toCheck.length; index++) { | ||
if (weightsMethod1[index] === 1) { | ||
sum += parseInt(toCheck.charAt(index), 10) * weightsMethod1[index]; | ||
} | ||
else { | ||
var value = parseInt(toCheck.charAt(index), 10) * weightsMethod1[index]; | ||
sum += Math.floor(value / 10) + (value % 10); | ||
} | ||
else { | ||
var value = parseInt(toCheck.charAt(index), 10) * weights[index]; | ||
sum += Math.floor(value / 10) + (value % 10); | ||
} | ||
var extraSum = sum + controlDigit; | ||
var multiDigit = Math.floor(extraSum / 10); | ||
var result = multiDigit * 10; | ||
var remainder = result - sum; | ||
return remainder === controlDigit; | ||
} | ||
var extraSum = sum + controlDigit; | ||
var multiDigit = Math.floor(extraSum / 10); | ||
var result = multiDigit * 10; | ||
var remainder = result - sum; | ||
return remainder === controlDigit; | ||
}; | ||
@@ -635,0 +625,0 @@ /** |
{ | ||
"name": "ibantools", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff like ISO 3136-1 alpha 2 country list", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
108386
3116