mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
closes #6502, also fixed issue with type: 'literal' in config.json
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
var async = require('async');
|
||||
var fs = require('fs');
|
||||
var url = require('url');
|
||||
var path = require('path');
|
||||
var prompt = require('prompt');
|
||||
var winston = require('winston');
|
||||
@@ -16,9 +17,7 @@ questions.main = [
|
||||
name: 'url',
|
||||
description: 'URL used to access this NodeBB',
|
||||
default:
|
||||
nconf.get('url') ||
|
||||
(nconf.get('base_url') ? (nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '')) : null) || // backwards compatibility (remove for v0.7.0)
|
||||
'http://localhost:4567',
|
||||
nconf.get('url') || 'http://localhost:4567',
|
||||
pattern: /^http(?:s)?:\/\//,
|
||||
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
||||
},
|
||||
@@ -162,7 +161,6 @@ function completeConfigSetup(config, next) {
|
||||
config.package_manager = nconf.get('package_manager');
|
||||
}
|
||||
|
||||
nconf.overrides(config);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
require('./database').init(next);
|
||||
@@ -171,6 +169,22 @@ function completeConfigSetup(config, next) {
|
||||
require('./database').createIndices(next);
|
||||
},
|
||||
function (next) {
|
||||
// Sanity-check/fix url/port
|
||||
if (!/^http(?:s)?:\/\//.test(config.url)) {
|
||||
config.url = 'http://' + config.url;
|
||||
}
|
||||
var urlObj = url.parse(config.url);
|
||||
if (urlObj.port) {
|
||||
config.port = urlObj.port;
|
||||
}
|
||||
urlObj.pathname = null;
|
||||
urlObj.path = null;
|
||||
|
||||
config.url = url.format(urlObj);
|
||||
|
||||
// ref: https://github.com/indexzero/nconf/issues/300
|
||||
delete config.type;
|
||||
|
||||
install.save(config, next);
|
||||
},
|
||||
], next);
|
||||
|
||||
Reference in New Issue
Block a user