catalog: encode entity name in EntityRefLink
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
committed by
Fredrik Adelöw
parent
ed5b9732ed
commit
c0ed2394f5
@@ -174,4 +174,26 @@ describe('<EntityRefLink />', () => {
|
||||
'/catalog/test/component/software',
|
||||
);
|
||||
});
|
||||
|
||||
it('renders link by encoding name as URI component', async () => {
|
||||
const entityName = {
|
||||
kind: 'Component',
|
||||
namespace: 'test',
|
||||
name: 'softw#are',
|
||||
};
|
||||
await renderInTestApp(
|
||||
<EntityRefLink entityRef={entityName} defaultKind="component">
|
||||
Custom Children
|
||||
</EntityRefLink>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(screen.getByText('Custom Children')).toHaveAttribute(
|
||||
'href',
|
||||
'/catalog/test/component/softw%23are',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ export const EntityRefLink = forwardRef<any, EntityRefLinkProps>(
|
||||
kind = kind.toLocaleLowerCase('en-US');
|
||||
namespace = namespace?.toLocaleLowerCase('en-US') ?? DEFAULT_NAMESPACE;
|
||||
|
||||
const routeParams = { kind, namespace, name };
|
||||
const routeParams = { kind, namespace, name: encodeURIComponent(name) };
|
||||
const formattedEntityRefTitle = humanizeEntityRef(
|
||||
{ kind, namespace, name },
|
||||
{ defaultKind },
|
||||
|
||||
Reference in New Issue
Block a user