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:
commit
c07385b22f
2 changed files with 5 additions and 1 deletions
|
@ -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
3
src/utils/string.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports.spliceURL = function spliceURL() {
|
||||
return Array.from(arguments).reduce((lastResult, current) => lastResult + current).replace(/([^:])(\/)+(.)/g, `$1/$3`);
|
||||
};
|
Loading…
Reference in a new issue