Comparing version 1.0.3 to 1.0.4
@@ -6,3 +6,7 @@ "use strict"; | ||
module.exports = function fmtr(str, obj) { | ||
return _.template(_.isString(str) ? str : '', { interpolate: /\$\{([^\}]+)\}/gm })(obj); | ||
try { | ||
return _.template(_.isString(str) ? str : '', { interpolate: /\$\{([^\}]+)\}/gm })(obj); | ||
} catch (err) { | ||
return (_.isString(str) ? str : '').replace(/\$\{([^\}]+)\}/gm, ''); | ||
} | ||
}; |
{ | ||
"name": "fmtr", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "awesome string formatter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,2 +27,7 @@ "use strict"; | ||
it('should ignore undefined variables', function() { | ||
expect(fmtr('Xx ${foobar} xX')).to.be('Xx xX'); | ||
expect(fmtr('Xx ${foobar} xX', { baz: 123 })).to.be('Xx xX'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4466
33