1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Still render icon, just without href

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-17 07:58:53 -05:00
parent 2d87114f9e
commit 59b730deed

View File

@ -40,6 +40,8 @@ import loggerInjectable from "../../../common/logger.injectable";
const hrefValidation = /https?:\/\//; const hrefValidation = /https?:\/\//;
const hrefIsSafe = (href: string) => Boolean(href.match(hrefValidation));
/** /**
* Mapping between the local file names and the svgs * Mapping between the local file names and the svgs
* *
@ -255,19 +257,17 @@ const RawIcon = (props: IconProps & Dependencies) => {
} }
if (href) { if (href) {
if (hrefValidation.exec(href) === null) { if (hrefIsSafe(href)) {
logger.warn("[ICON]: href prop is unsafe, blocking", { href }); return (
<a
return null; {...iconProps}
href={href}
ref={ref}
/>
);
} }
return ( logger.warn("[ICON]: href prop is unsafe, blocking", { href });
<a
{...iconProps}
href={href}
ref={ref}
/>
);
} }
return <i {...iconProps} ref={ref} />; return <i {...iconProps} ref={ref} />;