0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

Merge pull request #400 from Meeeeow/fix_multiple_slash_in_resource_url

fix: 🐛 incorrect logo url with slash at the end of `url_prefix`
This commit is contained in:
Juan Picado @jotadeveloper 2017-11-06 17:39:29 -05:00 committed by GitHub
commit c07385b22f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

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

3
src/utils/string.js Normal file
View file

@ -0,0 +1,3 @@
module.exports.spliceURL = function spliceURL() {
return Array.from(arguments).reduce((lastResult, current) => lastResult + current).replace(/([^:])(\/)+(.)/g, `$1/$3`);
};