0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Aplly sugestions form review

* Reneame the methof and use camelCase
* Use ES6 template string
This commit is contained in:
Bart Dubois 2017-05-21 22:39:47 +02:00
parent ff05d779c4
commit 8927d7d144
2 changed files with 6 additions and 6 deletions

View file

@ -44,7 +44,7 @@ module.exports = function(config, auth, storage) {
template = Handlebars.compile(fs.readFileSync(require.resolve('./GUI/index.hbs'), 'utf8'));
}
app.get('/', function(req, res, next) {
let base = Utils.get_base_url(req.protocol, req.get('host'), config.url_prefix);
let base = Utils.combineBaseUrl(req.protocol, req.get('host'), config.url_prefix);
res.setHeader('Content-Type', 'text/html');
storage.get_local(function(err, packages) {

View file

@ -87,14 +87,14 @@ function validate_metadata(object, name) {
* @param {String} prefix
* @return {String} base registry url
*/
function get_base_url(protocol, host, prefix) {
let result = protocol + '://' + host;
function combineBaseUrl(protocol, host, prefix) {
let result = '@{protocol}://@{host}';
if (prefix) {
prefix = prefix.replace(/\/$/, '');
result = (prefix.indexOf('/') === 0)
? result + prefix
? '@{result}@{prefix}'
: prefix;
}
@ -119,7 +119,7 @@ function filter_tarball_urls(pkg, req, config) {
return _url;
}
const filename = URL.parse(_url).pathname.replace(/^.*\//, '');
const base = get_base_url(req.protocol, req.headers.host, config.url_prefix);
const base = combineBaseUrl(req.protocol, req.headers.host, config.url_prefix);
return `${base}/${pkg.name.replace(/\//g, '%2f')}/-/${filename}`;
};
@ -280,7 +280,7 @@ module.exports.parse_address = parse_address;
module.exports.get_version = get_version;
module.exports.normalize_dist_tags = normalize_dist_tags;
module.exports.tag_version = tag_version;
module.exports.get_base_url = get_base_url;
module.exports.combineBaseUrl = combineBaseUrl;
module.exports.filter_tarball_urls = filter_tarball_urls;
module.exports.validate_metadata = validate_metadata;
module.exports.is_object = is_object;