Fix JS serving crash with promotions in the hash PV.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 21 Mar 2016 18:01:56 +0000 (19:01 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 21 Mar 2016 18:01:56 +0000 (19:01 +0100)
www/js/hash-lookup.js

index 9ecca53..ac89616 100644 (file)
@@ -55,7 +55,12 @@ var translate_line = function(board, fen, line, pretty_score) {
        var toplay = board.turn();
 
        if (line['move'] && line['move']['from_sq']) {
-               r['pretty_move'] = board.move({ from: line['move']['from_sq'], to: line['move']['to_sq'], promotion: line['move']['promotion'] }).san;
+               var promo = line['move']['promotion'];
+               if (promo) {
+                       r['pretty_move'] = board.move({ from: line['move']['from_sq'], to: line['move']['to_sq'], promotion: promo.toLowerCase() }).san;
+               } else {
+                       r['pretty_move'] = board.move({ from: line['move']['from_sq'], to: line['move']['to_sq'] }).san;
+               }
        } else {
                r['pretty_move'] = '';
        }