fix %0$s error

This commit is contained in:
Yaode_owo 2024-10-18 16:10:32 -04:00
parent 1174c9d163
commit e616214c72

View file

@ -238,7 +238,7 @@ function parseMinecraftMessage(component) {
translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = parseInt(index) - 1;
if (argIndex >= withArgs.length) {
if (argIndex < 0 || argIndex >= withArgs.length) {
DefaultMsg = true;
return match;
}
@ -322,11 +322,11 @@ function parseMinecraftMessageNoColor(component) {
translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => {
const argIndex = parseInt(index) - 1;
if (argIndex >= withArgs.length) {
if (argIndex < 0 || argIndex >= withArgs.length) {
DefaultMsg = true;
return match;
}
if (stringindex > 0 && string[stringindex - 1] === '%') {
return match;
}