Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(endpoint-badge): add logoSize support; test [endpoint] #10132

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/base-service/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions services/endpoint-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 10 additions & 0 deletions services/endpoint/endpoint.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ The endpoint badge takes a single required query param: <code>url</code>, which
the query string. Only works for simple-icons logos.
</td>
</tr>
<tr>
<td><code>logoSize</code></td>
<td>
Default: none. Make icons adaptively resize by setting <code>auto</code>.
Useful for some wider logos like <code>amd</code> and <code>amg</code>.
Supported for simple-icons logos only.
</td>
</tr>
<tr>
<td><code>logoWidth</code></td>
<td>
Expand Down Expand Up @@ -147,6 +155,7 @@ export default class Endpoint extends BaseJsonService {
namedLogo,
logoSvg,
logoColor,
logoSize,
logoWidth,
style,
cacheSeconds,
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions services/endpoint/endpoint.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading