Accept empty config values

Fixes #3977.
This commit is contained in:
Christoph Atteneder 2020-02-17 12:27:32 +01:00
parent 0083343178
commit 3899f693da
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
2 changed files with 10 additions and 1 deletions

View File

@ -20,7 +20,7 @@ class ConfigFileOption {
String[] tokens = clean(option).split("=");
String name = tokens[0].trim();
String arg = tokens[1].trim();
String arg = tokens.length > 1 ? tokens[1].trim() : "";
return new ConfigFileOption(name, arg);
}

View File

@ -33,4 +33,13 @@ public class ConfigFileOptionTests {
assertThat(option.arg, equalTo("example.com:8080"));
assertThat(option.toString(), equalTo("host1=example.com:8080"));
}
@Test
public void whenOptionHasNoValue_thenItSetsEmptyValue() {
String value = "host1=";
ConfigFileOption option = ConfigFileOption.parse(value);
assertThat(option.name, equalTo("host1"));
assertThat(option.arg, equalTo(""));
assertThat(option.toString(), equalTo("host1="));
}
}