Merge pull request #3978 from ripcurlx/accept-empty-option-values

Accept empty config values
This commit is contained in:
sqrrm 2020-02-17 19:22:08 +01:00 committed by GitHub
commit c411f48d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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="));
}
}