Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function saveShield(subject, status, color, icon) {
function escape(obj) {
return obj.toString().replace(/_/g, '__').replace(/-/g, '--').replace(/ /g, '_');
}
subject = escape(subject);
status = escape(status);
var url = new URI(`https://img.shields.io/badge/${subject}-${status}-${color}.svg`);
if (icon) {
var base64 = URI.encodeQuery(icon.toString('base64'));
url.addQuery('logo', 'data:image/png;base64,' + base64);
}
return makeRequest.getRaw(url.href(), { retries: 10 })
.then(data => {
util.saveFile(`deploy/badges/${subject.toLowerCase()}.svg`, data);
});
}