Merge pull request #29959 from benjidotsh/catalog-model/fix-icon-validation

fix(catalog-model): add support for icons containing colons
This commit is contained in:
Patrik Oldsberg
2025-05-20 10:09:50 +02:00
committed by GitHub
3 changed files with 9 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/catalog-model': patch
---
Added support for icons containing colons
@@ -197,7 +197,7 @@ describe('FieldFormatEntityPolicy', () => {
},
);
it.each([[123], [{}], [[]], ['abc xyz']])(
it.each([[123], [{}], [[]]])(
'rejects bad link icon value %s',
async (icon: unknown) => {
data.metadata.links = [{ url: 'http://foo', icon }];
@@ -208,10 +208,8 @@ describe('FieldFormatEntityPolicy', () => {
it('rejects a single bad link icon value', async () => {
data.metadata.links = [
{ url: 'http://foo', icon: 'good' },
{ url: 'http://foo', icon: 'not good' },
{ url: 'http://foo', icon: 123 },
];
await expect(policy.enforce(data)).rejects.toThrow(
/links.1.icon.*"not good"/i,
);
await expect(policy.enforce(data)).rejects.toThrow(/links.1.icon.*"123"/i);
});
});
@@ -161,7 +161,7 @@ export class FieldFormatEntityPolicy implements EntityPolicy {
optional(
`links.${i}.icon`,
links[i]?.icon,
KubernetesValidatorFunctions.isValidObjectName,
CommonValidatorFunctions.isNonEmptyString,
);
}