off by one in formatISBN
This commit is contained in:
parent
8a96a0a095
commit
0b7beec62d
1 changed files with 2 additions and 2 deletions
|
@ -653,13 +653,13 @@ Ox.formatISBN = function(isbn, length) {
|
|||
var ret = '';
|
||||
function getCheckDigit(isbn) {
|
||||
var mod = isbn.length == 10 ? 11 : 10
|
||||
return (mod - Ox.sum(
|
||||
return (Ox.mod(mod - Ox.sum(
|
||||
isbn.slice(0, -1).split('').map(function(digit, index) {
|
||||
return isbn.length == 10
|
||||
? parseInt(digit) * (10 - index)
|
||||
: parseInt(digit) * (index % 2 == 0 ? 1 : 3);
|
||||
})
|
||||
) % mod + '').replace('10', 'X');
|
||||
), mod) + '').replace('10', 'X');
|
||||
}
|
||||
isbn = isbn.toUpperCase().replace(/[^\dX]/g, '');
|
||||
if (isbn.length == 10) {
|
||||
|
|
Loading…
Reference in a new issue