closes #6502, also fixed issue with type: 'literal' in config.json

This commit is contained in:
Julian Lam
2018-05-15 15:25:59 -04:00
parent 87a5e777f1
commit 943d33ed09
3 changed files with 36 additions and 4 deletions

View File

@@ -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);