diff --git a/lib/config.js b/lib/config.js index 552776a..c555b6e 100644 --- a/lib/config.js +++ b/lib/config.js @@ -23,6 +23,10 @@ function removeEmpty (obj) { return _.omit(obj, _.isEmpty) } +function ensureLeadingSlash (path) { + return path.length && path[0] !== '/' ? '/' + path : path +} + /** * Parse a boolean config variable. * @@ -78,12 +82,7 @@ function parseServerConfig (prefix) { let port = parseInt(getEnv(prefix, 'PORT'), 10) || 3000 let public_host = getEnv(prefix, 'HOSTNAME') || require('os').hostname() let public_port = parseInt(getEnv(prefix, 'PUBLIC_PORT'), 10) || port - let public_path = getEnv(prefix, 'PUBLIC_PATH') || '' - - // Ensure path starts with a slash - if (public_path.length && public_path[0] !== '/') { - public_path = '/' + public_path - } + const public_path = ensureLeadingSlash(getEnv(prefix, 'PUBLIC_PATH') || '') if (useTestConfig()) { public_host = 'localhost'