From eb7f17c3875b7d1c155199fda5267d43f1fad0c9 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 14 Oct 2024 12:49:15 +0100 Subject: [PATCH] `Utils.String.RemoveAt` would incorrectly calculate the slice index if it was > 0. It will now remove the correctly specified character. --- src/utils/string/RemoveAt.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/string/RemoveAt.js b/src/utils/string/RemoveAt.js index 88c6c1960d..88cf252020 100644 --- a/src/utils/string/RemoveAt.js +++ b/src/utils/string/RemoveAt.js @@ -6,12 +6,14 @@ /** * Takes a string and removes the character at the given index. + * + * The index is zero based. * * @function Phaser.Utils.String.RemoveAt * @since 3.50.0 * * @param {string} string - The string to be worked on. - * @param {number} index - The index of the character to be removed. + * @param {number} index - The index of the character to be removed. This value is zero-based. * * @return {string} The modified string. */ @@ -23,7 +25,7 @@ var RemoveAt = function (string, index) } else { - return string.slice(0, index - 1) + string.slice(index); + return string.slice(0, index) + string.slice(index + 1); } };