strip leading slashes from path if double-slash is accidentally used, stripping trailing slash from relative path retrieved from config.json

This commit is contained in:
Julian Lam
2017-07-25 10:39:57 -04:00
parent 5835334b1c
commit 233297367b
3 changed files with 12 additions and 1 deletions

View File

@@ -93,7 +93,7 @@ function setupConfigs() {
}
// Parse out the relative_url and other goodies from the configured URL
var urlObject = url.parse(nconf.get('url'));
var relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
var relativePath = urlObject.pathname !== '/' ? urlObject.pathname.replace(/\/+$/, '') : '';
nconf.set('base_url', urlObject.protocol + '//' + urlObject.host);
nconf.set('secure', urlObject.protocol === 'https:');
nconf.set('use_port', !!urlObject.port);