Merge pull request #2541 from vector-im/dbkr/blank_config_3

Better support no-config when loading from file
This commit is contained in:
Richard van der Hoff 2016-11-03 14:56:16 +00:00 committed by GitHub
commit 4dab36d3b2
1 changed files with 9 additions and 6 deletions

View File

@ -179,13 +179,16 @@ function getConfig() {
if (err || response.status < 200 || response.status >= 300) { if (err || response.status < 200 || response.status >= 300) {
// Lack of a config isn't an error, we should // Lack of a config isn't an error, we should
// just use the defaults. // just use the defaults.
// Also treat a blank config as no config because // Also treat a blank config as no config, assuming
// we don't get 404s from file: URIs so this is the // the status code is 0, because we don't get 404s
// only way we can not fail if the file doesn't exist // from file: URIs so this is the only way we can
// when loading from a file:// URI. // not fail if the file doesn't exist when loading
if (( response && response.status == 404) || body == '') { // from a file:// URI.
if (response) {
if (response.status == 404 || (response.status == 0 && body == '')) {
deferred.resolve({}); deferred.resolve({});
} }
}
deferred.reject({err: err, response: response}); deferred.reject({err: err, response: response});
return; return;
} }