Skip to content

Commit

Permalink
Client-side URL redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
vrubezhny committed Oct 12, 2023
1 parent f51a137 commit 06d05d3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/webview/common/devfileListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ import { Box, Chip, Stack, Tooltip, Typography } from '@mui/material';
import * as React from 'react';
import { Devfile } from '../common/devfile';
import DevfileLogo from '../../../images/context/devfile.png';
import validator from 'validator'

export type DevfileListItemProps = {
devfile: Devfile;
buttonCallback?: () => void;
};

function checkedDevfileLogoUrl(logoUrl?: string) {
if (logoUrl && validator.isURL(logoUrl)) {
return logoUrl;
}
return DevfileLogo;
}

export function DevfileListItem(props: DevfileListItemProps) {
return (
<>
Expand Down Expand Up @@ -57,7 +65,7 @@ function DevfileListContent(props: DevfileListItemProps) {
borderRadius: '4px',
}}
>
<img src={props.devfile.logoUrl ? props.devfile.logoUrl : DevfileLogo} style={{ maxWidth: '6em', maxHeight: '6em' }} />
<img src={checkedDevfileLogoUrl(props.devfile.logoUrl)} style={{ maxWidth: '6em', maxHeight: '6em' }} />
</Box>
<Stack
direction="column"
Expand Down

0 comments on commit 06d05d3

Please sign in to comment.