]> git.sesse.net Git - remoteglot/commitdiff
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 9ecca5389009227a14bef7d785af39f52a989ba3..ac896164d1e338c86038a45b82e97fb263dc93cf 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']) {
        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'] = '';
        }
        } else {
                r['pretty_move'] = '';
        }