Skip to content

Commit 42e7808

Browse files
authored
remove logoWidth param (#10878)
* remove `logoWidth` param Fixes #10285 * remove `logoWidth` param Fixes #10285 * fix: add `logoWidth` parameter to BaseService test
1 parent 779f8ae commit 42e7808

File tree

7 files changed

+6
-43
lines changed

7 files changed

+6
-43
lines changed

core/base-service/base.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ const optionalStringWhenNamedLogoPresent = Joi.alternatives().conditional(
4747
},
4848
)
4949

50-
const optionalNumberWhenAnyLogoPresent = Joi.alternatives()
51-
.conditional('namedLogo', { is: Joi.string().required(), then: Joi.number() })
52-
.conditional('logoSvg', { is: Joi.string().required(), then: Joi.number() })
53-
5450
const serviceDataSchema = Joi.object({
5551
isError: Joi.boolean(),
5652
label: Joi.string().allow(''),
@@ -66,7 +62,6 @@ const serviceDataSchema = Joi.object({
6662
logoSvg: Joi.string(),
6763
logoColor: optionalStringWhenNamedLogoPresent,
6864
logoSize: optionalStringWhenNamedLogoPresent,
69-
logoWidth: optionalNumberWhenAnyLogoPresent,
7065
cacheSeconds: Joi.number().integer().min(0),
7166
style: Joi.string(),
7267
})

core/base-service/coalesce-badge.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import toArray from './to-array.js'
2020
// 1. When `?logo=` contains a simple-icons logo or contains a base64-encoded
2121
// SVG, that logo is used. When a `&logoColor=` is specified, that color is
2222
// used (except for the base64-encoded logos). Otherwise the default color
23-
// is used. The appearance of the logo can be customized using `logoWidth`,
23+
// is used.
2424
// When `?logo=` is specified, any logo-related parameters specified
2525
// dynamically by the service, or by default in the service, are ignored.
2626
// 2. The second precedence is the dynamic logo returned by a service. This is
@@ -52,11 +52,7 @@ export default function coalesceBadge(
5252
colorB: legacyOverrideColor,
5353
colorA: legacyOverrideLabelColor,
5454
} = overrides
55-
let {
56-
logoWidth: overrideLogoWidth,
57-
color: overrideColor,
58-
labelColor: overrideLabelColor,
59-
} = overrides
55+
let { color: overrideColor, labelColor: overrideLabelColor } = overrides
6056

6157
// Only use the legacy properties if the new ones are not provided
6258
if (typeof overrideColor === 'undefined') {
@@ -73,7 +69,6 @@ export default function coalesceBadge(
7369
if (typeof overrideLabelColor === 'number') {
7470
overrideLabelColor = `${overrideLabelColor}`
7571
}
76-
overrideLogoWidth = +overrideLogoWidth || undefined
7772

7873
const {
7974
isError,
@@ -85,7 +80,6 @@ export default function coalesceBadge(
8580
namedLogo: serviceNamedLogo,
8681
logoColor: serviceLogoColor,
8782
logoSize: serviceLogoSize,
88-
logoWidth: serviceLogoWidth,
8983
link: serviceLink,
9084
cacheSeconds: serviceCacheSeconds,
9185
style: serviceStyle,
@@ -131,7 +125,6 @@ export default function coalesceBadge(
131125
// If the logo has been overridden it does not make sense to inherit the
132126
// original width or position.
133127
logoSize = overrideLogoSize
134-
logoWidth = overrideLogoWidth
135128
} else {
136129
if (serviceLogoSvg) {
137130
logoSvgBase64 = svg2base64(serviceLogoSvg)
@@ -143,12 +136,11 @@ export default function coalesceBadge(
143136
namedLogoColor = coalesce(overrideLogoColor, serviceLogoColor)
144137
}
145138
logoSize = coalesce(overrideLogoSize, serviceLogoSize)
146-
logoWidth = coalesce(overrideLogoWidth, serviceLogoWidth)
147139
}
148140
if (namedLogo) {
149141
const iconSize = getIconSize(String(namedLogo).toLowerCase())
150142

151-
if (!logoWidth && iconSize && logoSize === 'auto') {
143+
if (iconSize && logoSize === 'auto') {
152144
logoWidth = (iconSize.width / iconSize.height) * DEFAULT_LOGO_HEIGHT
153145
}
154146

core/base-service/coalesce-badge.spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ describe('coalesceBadge', function () {
185185
{
186186
namedLogo: 'appveyor',
187187
logoColor: 'red',
188-
logoWidth: 100,
189188
},
190189
{},
191190
).logo,
@@ -246,20 +245,6 @@ describe('coalesceBadge', function () {
246245
})
247246
})
248247

249-
describe('Logo width', function () {
250-
it('overrides the logoWidth', function () {
251-
expect(coalesceBadge({ logoWidth: 20 }, {}, {})).to.include({
252-
logoWidth: 20,
253-
})
254-
})
255-
256-
it('applies the logo width', function () {
257-
expect(
258-
coalesceBadge({}, { namedLogo: 'npm', logoWidth: 275 }, {}),
259-
).to.include({ logoWidth: 275 })
260-
})
261-
})
262-
263248
describe('Links', function () {
264249
it('overrides the links', function () {
265250
expect(

core/base-service/legacy-request-handler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const globalQueryParams = new Set([
1212
'logo',
1313
'logoColor',
1414
'logoSize',
15-
'logoWidth',
1615
'link',
1716
'colorA',
1817
'colorB',

services/endpoint-common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const endpointSchema = Joi.object({
3636
logoSvg: Joi.string(),
3737
logoColor: optionalStringWhenNamedLogoPresent,
3838
logoSize: optionalStringWhenNamedLogoPresent,
39-
logoWidth: optionalNumberWhenAnyLogoPresent,
4039
style: Joi.string(),
4140
cacheSeconds: Joi.number().integer().min(0),
4241
/*
@@ -45,6 +44,7 @@ const endpointSchema = Joi.object({
4544
passing it should not throw an error
4645
*/
4746
logoPosition: optionalNumberWhenAnyLogoPresent,
47+
logoWidth: optionalNumberWhenAnyLogoPresent,
4848
})
4949
// `namedLogo` or `logoSvg`; not both.
5050
.oxor('namedLogo', 'logoSvg')

services/endpoint/endpoint.service.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@ The endpoint badge takes a single required query param: <code>url</code>, which
101101
Supported for simple-icons logos only.
102102
</td>
103103
</tr>
104-
<tr>
105-
<td><code>logoWidth</code></td>
106-
<td>
107-
Default: none. Same meaning as the query string. Can be overridden by
108-
the query string.
109-
</td>
110-
</tr>
111104
<tr>
112105
<td><code>style</code></td>
113106
<td>
@@ -156,7 +149,6 @@ export default class Endpoint extends BaseJsonService {
156149
logoSvg,
157150
logoColor,
158151
logoSize,
159-
logoWidth,
160152
style,
161153
cacheSeconds,
162154
}) {
@@ -170,7 +162,6 @@ export default class Endpoint extends BaseJsonService {
170162
logoSvg,
171163
logoColor,
172164
logoSize,
173-
logoWidth,
174165
style,
175166
// don't allow the user to set cacheSeconds any shorter than this._cacheLength
176167
cacheSeconds: Math.max(

services/endpoint/endpoint.tester.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ t.create('custom svg logo')
118118
expect(body).to.include(getSimpleIcon({ name: 'npm' }))
119119
})
120120

121+
// The logoWidth param was removed, but passing it should not
122+
// throw a validation error. It should just do nothing.
121123
t.create('logoWidth')
122124
.get('.json?url=https://example.com/badge')
123125
.intercept(nock =>
@@ -132,7 +134,6 @@ t.create('logoWidth')
132134
.expectBadge({
133135
label: 'hey',
134136
message: 'yo',
135-
logoWidth: 30,
136137
})
137138

138139
// The logoPosition param was removed, but passing it should not

0 commit comments

Comments
 (0)