Commit 0d4af79c authored by Zhou Fang's avatar Zhou Fang Committed by Martin Lowe
Browse files

#482 Added validation for org website before linking it to org logo

parent fb88dc94
......@@ -166,13 +166,22 @@ export default function DashboardIntro() {
return <Typography variant="body1">{errMsgForGetRequest}</Typography>;
}
let isWebsiteValid = false;
try {
// This will fail if the URL is not valid
new URL(orgIntro.website);
isWebsiteValid = true;
} catch (error) {
console.log(error);
}
return (
// Org logo will not be clickable if the website URL doesn't exist
// Org logo will not be clickable if the website URL does NOT exist or is NOT valid
<Link
href={orgIntro.website}
target="_blank"
rel="noreferrer"
className={orgIntro.website ? '' : classes.urlNotClickable}
className={isWebsiteValid ? '' : classes.urlNotClickable}
>
{orgIntro.imageURL ? (
<CardMedia component="img" className={classes.companyLogo} image={orgIntro.imageURL} alt={orgIntro.name} />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment