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:
parent
2d87114f9e
commit
59b730deed
@ -40,6 +40,8 @@ import loggerInjectable from "../../../common/logger.injectable";
|
||||
|
||||
const hrefValidation = /https?:\/\//;
|
||||
|
||||
const hrefIsSafe = (href: string) => Boolean(href.match(hrefValidation));
|
||||
|
||||
/**
|
||||
* Mapping between the local file names and the svgs
|
||||
*
|
||||
@ -255,19 +257,17 @@ const RawIcon = (props: IconProps & Dependencies) => {
|
||||
}
|
||||
|
||||
if (href) {
|
||||
if (hrefValidation.exec(href) === null) {
|
||||
logger.warn("[ICON]: href prop is unsafe, blocking", { href });
|
||||
|
||||
return null;
|
||||
if (hrefIsSafe(href)) {
|
||||
return (
|
||||
<a
|
||||
{...iconProps}
|
||||
href={href}
|
||||
ref={ref}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<a
|
||||
{...iconProps}
|
||||
href={href}
|
||||
ref={ref}
|
||||
/>
|
||||
);
|
||||
logger.warn("[ICON]: href prop is unsafe, blocking", { href });
|
||||
}
|
||||
|
||||
return <i {...iconProps} ref={ref} />;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user