diff --git a/server.js b/server.js index b3d3d05..7c49771 100644 --- a/server.js +++ b/server.js @@ -2,6 +2,7 @@ var secureServer = !!process.env.HTTPS; var serverPort = +process.env.PORT || +process.argv[2] || (secureServer? 443: 80); var bindAddress = process.env.BIND_ADDRESS || process.argv[3] || '::'; var infoSite = process.env.INFOSITE || "http://shields.io"; +var githubApiUrl = process.env.GITHUB_URL || 'https://api.github.com'; var Camp = require('camp'); var camp = Camp.start({ documentRoot: __dirname, @@ -2693,7 +2694,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, strongloop/express var repo = match[2]; var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/tags'; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo + '/tags'; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -2736,7 +2737,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, qubyte/rubidium var repo = match[2]; var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases/latest'; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo + '/releases/latest'; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -2780,7 +2781,7 @@ cache(function(data, match, sendBadge, request) { var repo = match[2]; // eg, subtitleedit var version = match[3]; // eg, 3.4.7 var format = match[4]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/compare/' + version + '...master'; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo + '/compare/' + version + '...master'; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -2831,7 +2832,7 @@ cache(function(data, match, sendBadge, request) { total = false; } - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases'; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo + '/releases'; if (!total) { var release_path = tag !== 'latest' ? 'tags/' + tag : 'latest'; apiUrl = apiUrl + '/' + release_path; @@ -2904,7 +2905,7 @@ cache(function(data, match, sendBadge, request) { var repo = match[3]; // eg, shields var ghLabel = match[4]; // eg, website var format = match[5]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo; var issuesApi = false; // Are we using the issues API instead of the repo one? var query = {}; if (ghLabel !== undefined) { @@ -2961,7 +2962,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, qubyte/rubidium var repo = match[2]; var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -3007,7 +3008,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, qubyte/rubidium var repo = match[2]; var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -3051,7 +3052,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, qubyte/rubidium var repo = match[2]; var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -3094,7 +3095,7 @@ camp.route(/^\/github\/followers\/([^\/]+)\.(svg|png|gif|jpg|json)$/, cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, qubyte var format = match[2]; - var apiUrl = 'https://api.github.com/users/' + user; + var apiUrl = githubApiUrl + '/users/' + user; // Using our OAuth App secret grants us 5000 req/hour // instead of the standard 60 req/hour. if (serverSecrets) { @@ -3134,7 +3135,7 @@ cache(function(data, match, sendBadge, request) { var user = match[1]; // eg, mashape var repo = match[2]; // eg, apistatus var format = match[3]; - var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo; + var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo; var badgeData = getBadgeData('license', data); if (badgeData.template === 'social') { badgeData.logo = badgeData.logo || logos.github;