Skip to content

Commit

Permalink
Replace case statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbk committed Dec 1, 2017
1 parent 14374f0 commit 47803f7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1080,19 +1080,14 @@ cache(function(data, match, sendBadge, request) {
var entity = match[2]; // e.g., 'Changaco'
var format = match[3];
var apiUrl = 'https://liberapay.com/' + entity + '/public.json';
// Establish default
var badgeData = getBadgeData('receives', data);
switch(type) {
case 'gives':
badgeData = getBadgeData('gives', data);
break;
case 'patrons':
badgeData = getBadgeData('patrons', data);
break;
case 'goal':
badgeData = getBadgeData('goal progress', data);
break;
}
// Lock down type
const label = {
'receives': 'receives',
'gives': 'gives',
'patrons': 'patrons',
'goal': 'goal progress',
}[type];
const badgeData = getBadgeData(label, data);
if (badgeData.template === 'social') {
badgeData.logo = getLogo('liberapay', data);
}
Expand Down

0 comments on commit 47803f7

Please sign in to comment.