text: actually fix remove levels properly
This commit is contained in:
@@ -88,16 +88,17 @@ public class Text
|
|||||||
*/
|
*/
|
||||||
public static String removeTags(String str, boolean removeLevels)
|
public static String removeTags(String str, boolean removeLevels)
|
||||||
{
|
{
|
||||||
int strLen = str.length();
|
|
||||||
if (removeLevels)
|
if (removeLevels)
|
||||||
{
|
{
|
||||||
int levelIdx = StringUtils.lastIndexOf(str, " (level");
|
int levelIdx = StringUtils.lastIndexOf(str, " (level");
|
||||||
if (levelIdx >= 0)
|
if (levelIdx >= 0)
|
||||||
{
|
{
|
||||||
strLen = levelIdx + 1;
|
str = str.substring(0, levelIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strLen = str.length();
|
||||||
|
|
||||||
int open, close;
|
int open, close;
|
||||||
if ((open = StringUtils.indexOf(str, '<')) == -1
|
if ((open = StringUtils.indexOf(str, '<')) == -1
|
||||||
|| (close = StringUtils.indexOf(str, '>', open)) == -1)
|
|| (close = StringUtils.indexOf(str, '>', open)) == -1)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class TextTest
|
|||||||
assertEquals("a < b", Text.removeTags("a < b"));
|
assertEquals("a < b", Text.removeTags("a < b"));
|
||||||
assertEquals("Remove no tags", Text.removeTags("Remove no tags"));
|
assertEquals("Remove no tags", Text.removeTags("Remove no tags"));
|
||||||
assertEquals("Zezima", Text.removeTags("<col=ffffff><img=2>Zezima<col=00ffff> (level-126)", true));
|
assertEquals("Zezima", Text.removeTags("<col=ffffff><img=2>Zezima<col=00ffff> (level-126)", true));
|
||||||
|
assertEquals("Zezima", Text.removeTags("Zezima (level-126)", true));
|
||||||
assertEquals("", Text.removeTags("<col=ffffff><img=2><col=00ffff> (level-126)", true));
|
assertEquals("", Text.removeTags("<col=ffffff><img=2><col=00ffff> (level-126)", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user