Coerce text to string.
Caused issues with numbers being .replace()'d.
This commit is contained in:
parent
7572a829f9
commit
2e868d1e12
|
@ -19,7 +19,7 @@ npm install gh-badges
|
|||
```js
|
||||
var badge = require('gh-badges');
|
||||
badge({ text: [ "build", "passed" ], colorscheme: "green" },
|
||||
function(svg) {
|
||||
function(svg, err) {
|
||||
// svg is a String… of your badge.
|
||||
});
|
||||
```
|
||||
|
|
11
badge.js
11
badge.js
|
@ -52,6 +52,10 @@ function makeImage(data, cb) {
|
|||
if (!(data.template + '-' + data.format in templates)) {
|
||||
data.template = 'default';
|
||||
}
|
||||
// String coercion.
|
||||
data.text[0] = '' + data.text[0];
|
||||
data.text[1] = '' + data.text[1];
|
||||
|
||||
var template = templates[data.template + '-' + data.format];
|
||||
if (data.colorscheme) {
|
||||
data.colorA = colorscheme[data.colorscheme].colorA;
|
||||
|
@ -63,7 +67,12 @@ function makeImage(data, cb) {
|
|||
];
|
||||
|
||||
addEscapers(data);
|
||||
var result = template(data);
|
||||
try {
|
||||
var result = template(data);
|
||||
} catch(e) {
|
||||
cb('', e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.format === 'json') {
|
||||
cb(result);
|
||||
|
|
Loading…
Reference in New Issue
Block a user