diff --git a/src/api/web/index.js b/src/api/web/index.js index e1d23a942..97cc739ab 100644 --- a/src/api/web/index.js +++ b/src/api/web/index.js @@ -10,6 +10,7 @@ const _ = require('lodash'); const env = require('../../config/env'); const fs = require('fs'); const template = fs.readFileSync(`${env.DIST_PATH}/index.html`).toString(); +const spliceURL = require('../../utils/string').spliceURL; module.exports = function(config, auth, storage) { Search.configureStorage(storage); @@ -35,7 +36,7 @@ module.exports = function(config, auth, storage) { router.get('/-/verdaccio/logo', function(req, res) { const installPath = _.get(config, 'url_prefix', ''); - res.send(_.get(config, 'web.logo') || `${installPath}/-/static/logo.png`); + res.send(_.get(config, 'web.logo') || spliceURL(installPath, '/-/static/logo.png')); }); router.get('/', function(req, res) { diff --git a/src/utils/string.js b/src/utils/string.js new file mode 100644 index 000000000..77f62902d --- /dev/null +++ b/src/utils/string.js @@ -0,0 +1,3 @@ +module.exports.spliceURL = function spliceURL() { + return Array.from(arguments).reduce((lastResult, current) => lastResult + current).replace(/([^:])(\/)+(.)/g, `$1/$3`); +};