mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
fix unicodeTrim on all-whitespace strings
This commit is contained in:
parent
41b9d5c68b
commit
e9fe426f7f
@ -79,7 +79,7 @@ final public class ConfigUtil {
|
||||
return s;
|
||||
|
||||
int start = 0;
|
||||
while (true) {
|
||||
while (start < length) {
|
||||
char c = s.charAt(start);
|
||||
if (c == ' ' || c == '\n') {
|
||||
start += 1;
|
||||
@ -93,7 +93,7 @@ final public class ConfigUtil {
|
||||
}
|
||||
|
||||
int end = length;
|
||||
while (true) {
|
||||
while (end > start) {
|
||||
char c = s.charAt(end - 1);
|
||||
if (c == ' ' || c == '\n') {
|
||||
--end;
|
||||
|
@ -21,6 +21,7 @@ class UtilTest extends TestUtils {
|
||||
assertEquals("", ConfigUtil.unicodeTrim(""))
|
||||
assertEquals("a", ConfigUtil.unicodeTrim("a"))
|
||||
assertEquals("abc", ConfigUtil.unicodeTrim("abc"))
|
||||
assertEquals("", ConfigUtil.unicodeTrim(" \n \n \u00A0 "))
|
||||
assertEquals(supplementaryChars, ConfigUtil.unicodeTrim(supplementaryChars))
|
||||
|
||||
val s = " \u00A0 \n " + supplementaryChars + " \n \u00A0 "
|
||||
|
Loading…
Reference in New Issue
Block a user