From b143b8f6f887ce58808edfd3ee4d3eac14bd803b Mon Sep 17 00:00:00 2001 From: Francisco Salgueiro Date: Mon, 2 Oct 2023 18:37:56 +0100 Subject: [PATCH] fix infinite recursion on getting opening name --- src/utils/chess.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/chess.ts b/src/utils/chess.ts index fbd7fb2c..fa473b0e 100644 --- a/src/utils/chess.ts +++ b/src/utils/chess.ts @@ -362,7 +362,7 @@ export async function getOpening( } return invoke("get_opening_from_fen", { fen: tree.fen }) .then((v) => v) - .catch(() => getOpening(root, position.slice(0, -1))); + .catch(() => position.length === 0 ? "" : getOpening(root, position.slice(0, -1))); } export function swapMove(fen: string, color?: Color) {