Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rpl/badge-up

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpl/badge-up - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

.editorconfig

20

index.js

@@ -6,7 +6,5 @@ /*

/* jshint unused:false */
var fs = require('fs'),
path = require('path'),
SVGO = require('svgo'),
svgo = new SVGO(),
svgo = require('svgo'),
dot = require('dot'),

@@ -42,5 +40,15 @@ template = dot.template(fs.readFileSync(path.join(__dirname, 'templates', 'basic.svg'), 'utf-8')),

// Run the SVG through SVGO.
svgo.optimize(template(data)).then(function (object) {
callback(null, object.data);
}).catch(callback);
const raw = utils.fixupNumericEntities(template(data));
const optimized = svgo.optimize(raw, {
plugins: ['preset-default'],
});
if (optimized.modernError) {
if (callback) {
callback(optimized.modernError, undefined);
return;
}
return Promise.reject(optimized.modernError);
}
if (callback) callback(null, optimized.data);
return Promise.resolve(optimized.data);
};

@@ -47,0 +55,0 @@

{
"name": "@rpl/badge-up",
"version": "2.2.0",
"description": "A module that produces hot badges without the need of Cairo (forked from the original badge-up package to update vulnerable npm deps)",
"version": "3.0.0",
"description": "A module that produces hot badges without the need of Cairo",
"main": "index.js",
"nyc": {
"reporter": [
"lcov",
"text"
]
},
"scripts": {
"lint": "jshint *.js test/*.js",
"test": "jenkins-mocha"
"lint": "eslint .",
"test": "nyc --report-dir ./artifacts/coverage mocha --color true",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},

@@ -14,5 +21,10 @@ "repository": {

},
"bugs": "https://github.com/yahoo/badge-up/issues",
"homepage": "https://github.com/rpl/badge-up",
"engines": {
"node": ">=10.0.0"
},
"bugs": "https://github.com/rpl/badge-up/issues",
"keywords": [
"badge"
"badge",
"yahoo"
],

@@ -28,17 +40,21 @@ "license": "BSD-3-Clause",

],
"jshintConfig": {
"node": true
"release": {
"debug": false,
"verifyConditions": {
"path": "./node_modules/semantic-release/src/lib/plugin-noop.js"
}
},
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^3.0.2",
"jenkins-mocha": "^6.0.0",
"jshint": "^2.9.2",
"sinon": "^1.17.7"
"chai": "^4.2.0",
"coveralls": "^3.0.11",
"eslint": "^6.8.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"sinon": "^9.0.1"
},
"dependencies": {
"css-color-names": "~0.0.3",
"dot": "^1.1.1",
"svgo": "^1.1.1"
"css-color-names": "~1.0.1",
"dot": "^1.1.3",
"svgo": "2.6.0"
}
}

@@ -1,10 +0,1 @@

# This is a forked version of the original [badge-up npm package](https://www.npmjs.com/package/badge-up)
The only changes applied to the original npm package are:
- updated npm dependencies (to fix some known vulnerabilities detected by npm audit)
- adapt sources to the changes introduced in the new `svgo` library
------
# badge-up

@@ -28,3 +19,3 @@

```js
var badge = require('badge-up');
const badge = require('badge-up');
badge('batman', 'component', badge.colors.green, function (error, svg) {

@@ -40,3 +31,15 @@ // some callback

You can alternatively use the returned `Promise`:
```js
const badge = require('badge-up');
(async () => {
try {
const svg = await badge('batman', 'component', badge.colors.green);
} catch (error) {
//
}
}());
```
## V2 Usage

@@ -63,9 +66,9 @@

```js
var badge = require('badge-up');
var sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
const badge = require('badge-up');
const sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
badge.v2(sections, function (error, svg) {

@@ -77,1 +80,21 @@ // some callback

Produces: ![example](https://cdn.rawgit.com/yahoo/badge-up/master/test/testData/v2-example.svg)
You can also use the returned `Promise`:
```js
const badge = require('badge-up');
const sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
(async () => {
try {
const svg = await badge.v2(sections);
} catch (error) {
//
}
}());
```

@@ -17,4 +17,15 @@ /*

];
/**
* Replace numeric entity codes with the related entity code name
* for the "<" and "&" characters. Prevent svgo "Unencoded ..." errors,
* see https://github.com/svg/svgo/issues/1498.
* @method replaceNumericEntities
* @param {String} string Input string
* @return {String} Fixed string
*/
module.exports.fixupNumericEntities = function replaceNumericEntitities(string) {
return string.replace(/&#(x3c|60);/gi, '&lt;')
.replace(/&#(x26|38);/gi, '&amp;');
}
/**

@@ -21,0 +32,0 @@ * Escape the string so that it doesn't break xml

@@ -10,6 +10,4 @@ /*

path = require('path'),
utils = require('./utils'),
svgo = require('svgo'),
utils = require('./utils'),
SVGO = require('svgo'),
svgo = new SVGO(),
TEMPLATE = dot.template(fs.readFileSync(path.join(__dirname, 'templates', 'v2.svg'), 'utf-8')),

@@ -102,6 +100,26 @@ COLOR_REGEX = /^[0-9a-f]{6}$/i,

module.exports = function badge_v2(sections, callback) {
var raw = TEMPLATE(sectionsToData(sections));
svgo.optimize(raw).then(function(optimized) {
callback(undefined, optimized.data);
}).catch(callback);
var raw = utils.fixupNumericEntities(
TEMPLATE(sectionsToData(sections))
);
const optimized = svgo.optimize(raw, {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
sortDefsChildren: false,
}
}
}
],
})
if (optimized.modernError) {
if (callback) {
callback(optimized.modernError, undefined);
return;
}
return Promise.reject(optimized.modernError);
}
if (callback) callback(undefined, optimized.data);
return Promise.resolve(optimized.data);
};

@@ -108,0 +126,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc