Skip to content
This repository was archived by the owner on Jun 10, 2019. It is now read-only.

Commit e42277a

Browse files
RickRhollomancer
authored andcommitted
Adds external link check. Fixes #147, fixes #142
1 parent a2b911b commit e42277a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/shared/components/linkButton/linkButton.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { Link as ScrollLink } from 'react-scroll';
55
import styles from './linkButton.css';
66

77
const LinkButton = (props) => {
8+
function isExternalLink(link) {
9+
if (link.startsWith('http://') || link.startsWith('https://') || link.startsWith('mailto:')) { return true; }
10+
return false;
11+
}
12+
813
const {
914
link,
1015
text,
@@ -26,6 +31,12 @@ const LinkButton = (props) => {
2631
);
2732
}
2833

34+
if (isExternalLink(link)) {
35+
return (
36+
<a href={link} className={`${styles.linkButton} ${styles[theme]}`}>{text}</a>
37+
);
38+
}
39+
2940
return (
3041
<Link
3142
className={`${styles.linkButton} ${styles[theme]}`}

0 commit comments

Comments
 (0)