forked from sombochea/verdaccio-ui
fix: verify validation url and email (#60)
* fix: verify validation url and email * chore: disable one expect * fix: lint issue * fix: fix lint
This commit is contained in:
committed by
GitHub
parent
233ba196a0
commit
980dac5b2f
@@ -12,6 +12,7 @@ import Tooltip from '@material-ui/core/Tooltip/index';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/version/index';
|
||||
import { Fab, ActionListItem } from './styles';
|
||||
import { isURL } from '../../utils/url';
|
||||
|
||||
const ACTIONS = {
|
||||
homepage: {
|
||||
@@ -40,9 +41,6 @@ class ActionBar extends Component<any, any> {
|
||||
}
|
||||
|
||||
renderIconsWithLink(link, component) {
|
||||
if (!link) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<a href={link} target={'_blank'}>
|
||||
{component}
|
||||
@@ -61,7 +59,7 @@ class ActionBar extends Component<any, any> {
|
||||
|
||||
const renderList = Object.keys(actionsMap).reduce((component, value, key) => {
|
||||
const link = actionsMap[value];
|
||||
if (link) {
|
||||
if (link && isURL(link)) {
|
||||
const fab = <Fab size={'small'}>{ACTIONS[value]['icon']}</Fab>;
|
||||
component.push(
|
||||
<Tooltip key={key} title={ACTIONS[value]['title']}>
|
||||
|
||||
@@ -10,6 +10,7 @@ import ListItemText from '@material-ui/core/ListItemText/index';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/version/index';
|
||||
import { Heading, AuthorListItem } from './styles';
|
||||
import { isEmail } from '../../utils/url';
|
||||
|
||||
class Authors extends Component<any, any> {
|
||||
render() {
|
||||
@@ -23,9 +24,10 @@ class Authors extends Component<any, any> {
|
||||
}
|
||||
|
||||
renderLinkForMail(email, avatarComponent, packageName, version) {
|
||||
if (!email) {
|
||||
if (!email || isEmail(email) === false) {
|
||||
return avatarComponent;
|
||||
}
|
||||
|
||||
return (
|
||||
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
|
||||
{avatarComponent}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Tooltip from '@material-ui/core/Tooltip';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/version';
|
||||
import { Details, Heading, Content, Fab } from './styles';
|
||||
import { isEmail } from '../../utils/url';
|
||||
|
||||
interface Props {
|
||||
type: 'contributors' | 'maintainers';
|
||||
@@ -58,7 +59,7 @@ class Developers extends Component<Props, any> {
|
||||
};
|
||||
|
||||
renderLinkForMail(email, avatarComponent, packageName, version) {
|
||||
if (!email) {
|
||||
if (!email || isEmail(email) === false) {
|
||||
return avatarComponent;
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -34,6 +34,7 @@ import {
|
||||
Text,
|
||||
WrapperLink,
|
||||
} from './styles';
|
||||
import { isURL } from '../../utils/url';
|
||||
|
||||
const Package = ({
|
||||
author: { name: authorName, avatar: authorAvatar },
|
||||
@@ -92,7 +93,8 @@ const Package = ({
|
||||
);
|
||||
|
||||
const renderHomePageLink = () =>
|
||||
homepage && (
|
||||
homepage &&
|
||||
isURL(homepage) && (
|
||||
<a href={homepage} target={'_blank'}>
|
||||
<Tooltip aria-label={'Homepage'} title={'Visit homepage'}>
|
||||
<IconButton aria-label={'Homepage'}>
|
||||
@@ -104,7 +106,8 @@ const Package = ({
|
||||
);
|
||||
|
||||
const renderBugsLink = () =>
|
||||
url && (
|
||||
url &&
|
||||
isURL(url) && (
|
||||
<a href={url} target={'_blank'}>
|
||||
<Tooltip aria-label={'Bugs'} title={'Open an issue'}>
|
||||
<IconButton aria-label={'Bugs'}>
|
||||
|
||||
@@ -10,6 +10,7 @@ import CopyToClipBoard from '../CopyToClipBoard';
|
||||
|
||||
import { Heading, GithubLink, RepositoryListItem } from './styles';
|
||||
import git from './img/git.png';
|
||||
import { isURL } from '../../utils/url';
|
||||
|
||||
class Repository extends Component<any, any> {
|
||||
render() {
|
||||
@@ -33,7 +34,7 @@ class Repository extends Component<any, any> {
|
||||
} = {},
|
||||
} = packageMeta.latest;
|
||||
|
||||
if (!url) {
|
||||
if (!url || isURL(url) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user