mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05: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:
parent
fc89cf1d49
commit
c7bbaffec3
2 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue