From 0b7beec62d3530e44a8da2b5a6e507289df8ba75 Mon Sep 17 00:00:00 2001 From: rlx Date: Mon, 11 Jan 2016 18:47:14 +0530 Subject: [PATCH] off by one in formatISBN --- source/Ox/js/Format.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Ox/js/Format.js b/source/Ox/js/Format.js index b88a0b53..d151dc1a 100644 --- a/source/Ox/js/Format.js +++ b/source/Ox/js/Format.js @@ -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) {