diff --git a/core/base-service/base.js b/core/base-service/base.js index 8123150a503a0..fc1f881aac762 100644 --- a/core/base-service/base.js +++ b/core/base-service/base.js @@ -65,6 +65,7 @@ const serviceDataSchema = Joi.object({ namedLogo: Joi.string(), logoSvg: Joi.string(), logoColor: optionalStringWhenNamedLogoPresent, + logoSize: optionalStringWhenNamedLogoPresent, logoWidth: optionalNumberWhenAnyLogoPresent, cacheSeconds: Joi.number().integer().min(0), style: Joi.string(), diff --git a/services/endpoint-common.js b/services/endpoint-common.js index af89d76505f1d..919667655e2f2 100644 --- a/services/endpoint-common.js +++ b/services/endpoint-common.js @@ -35,6 +35,7 @@ const endpointSchema = Joi.object({ namedLogo: Joi.string(), logoSvg: Joi.string(), logoColor: optionalStringWhenNamedLogoPresent, + logoSize: optionalStringWhenNamedLogoPresent, logoWidth: optionalNumberWhenAnyLogoPresent, style: Joi.string(), cacheSeconds: Joi.number().integer().min(0), diff --git a/services/endpoint/endpoint.service.js b/services/endpoint/endpoint.service.js index bffd6fa8fe3f4..eb9d8e6acd1f4 100644 --- a/services/endpoint/endpoint.service.js +++ b/services/endpoint/endpoint.service.js @@ -93,6 +93,14 @@ The endpoint badge takes a single required query param: url, which the query string. Only works for simple-icons logos. + + logoSize + + Default: none. Make icons adaptively resize by setting auto. + Useful for some wider logos like amd and amg. + Supported for simple-icons logos only. + + logoWidth @@ -147,6 +155,7 @@ export default class Endpoint extends BaseJsonService { namedLogo, logoSvg, logoColor, + logoSize, logoWidth, style, cacheSeconds, @@ -160,6 +169,7 @@ export default class Endpoint extends BaseJsonService { namedLogo, logoSvg, logoColor, + logoSize, logoWidth, style, // don't allow the user to set cacheSeconds any shorter than this._cacheLength diff --git a/services/endpoint/endpoint.tester.js b/services/endpoint/endpoint.tester.js index c6f5186bdec4d..4cbaf2747aa7f 100644 --- a/services/endpoint/endpoint.tester.js +++ b/services/endpoint/endpoint.tester.js @@ -82,6 +82,22 @@ t.create('named logo with color') expect(body).to.include(getSimpleIcon({ name: 'github', color: 'blue' })) }) +t.create('named logo with size') + .get('.svg?url=https://example.com/badge') + .intercept(nock => + nock('https://example.com/').get('/badge').reply(200, { + schemaVersion: 1, + label: 'hey', + message: 'yo', + namedLogo: 'github', + logoSize: 'auto', + }), + ) + .after((err, res, body) => { + expect(err).not.to.be.ok + expect(body).to.include(getSimpleIcon({ name: 'github', size: 'auto' })) + }) + const logoSvg = Buffer.from( getSimpleIcon({ name: 'npm' }).replace('data:image/svg+xml;base64,', ''), 'base64',