1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-23 21:29:37 +02:00

Added url parser to support wider range of addresses

This commit is contained in:
unknown 2021-06-11 15:33:06 +02:00
parent 5968663be4
commit a5504e6e80
7 changed files with 63 additions and 24 deletions

View file

@ -1,8 +1,6 @@
import { Link } from 'react-router-dom';
import classes from './AppCard.module.css';
import Icon from '../../UI/Icons/Icon/Icon';
import { iconParser } from '../../../utility/iconParser';
import { iconParser, urlParser } from '../../../utility';
import { App } from '../../../interfaces';
@ -12,18 +10,16 @@ interface ComponentProps {
}
const AppCard = (props: ComponentProps): JSX.Element => {
const redirectHandler = (url: string): void => {
window.open(url);
}
const [displayUrl, redirectUrl] = urlParser(props.app.url);
return (
<a href={`http://${props.app.url}`} target='_blank' className={classes.AppCard}>
<a href={redirectUrl} target='_blank' className={classes.AppCard}>
<div className={classes.AppCardIcon}>
<Icon icon={iconParser(props.app.icon)} />
</div>
<div className={classes.AppCardDetails}>
<h5>{props.app.name}</h5>
<span>{props.app.url}</span>
<span>{displayUrl}</span>
</div>
</a>
)