2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

️ Throw clear error message when config.url has no protocol (#8466)

closes #8449

- throw a more clear error message
This commit is contained in:
Aileen Nowak 2017-05-22 01:00:11 +09:00 committed by Katharina Irrgang
parent fc89cf1d49
commit c7bbaffec3
2 changed files with 17 additions and 0 deletions

View file

@ -48,6 +48,12 @@ _private.loadNconf = function loadNconf(options) {
nconf.makePathsAbsolute(nconf.get('paths'), 'paths');
nconf.makePathsAbsolute(nconf.get('database:connection'), 'database:connection');
/**
* Check if the URL in config has a protocol
*/
nconf.checkUrlProtocol = localUtils.checkUrlProtocol.bind(nconf);
nconf.checkUrlProtocol();
/**
* values we have to set manual
*/

View file

@ -68,6 +68,17 @@ exports.getContentPath = function getContentPath(type) {
}
};
/**
* Check if the URL in config has a protocol and sanitise it if not including a warning that it should be changed
*/
exports.checkUrlProtocol = function checkUrlProtocol() {
var url = this.get('url');
if (!url.match(/^https?:\/\//i)) {
throw new Error('URL in config must be provided with protocol, eg. "http://my-ghost-blog.com"');
}
};
/**
* nconf merges all database keys together and this can be confusing
* e.g. production default database is sqlite, but you override the configuration with mysql