diff --git a/src/webui/src/components/PackageSidebar/modules/Infos/index.jsx b/src/webui/src/components/PackageSidebar/modules/Infos/index.jsx index f6f4f9b51..bdff8df79 100644 --- a/src/webui/src/components/PackageSidebar/modules/Infos/index.jsx +++ b/src/webui/src/components/PackageSidebar/modules/Infos/index.jsx @@ -2,6 +2,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import get from 'lodash/get'; import Module from '../../Module'; +import isString from 'lodash/isString'; +import isNil from 'lodash/isNil'; import classes from './style.scss'; @@ -19,21 +21,25 @@ export default class Infos extends React.Component { } normalizeInfo(infoObj) { - if (typeof infoObj === 'string') { + if (isString(infoObj)) { return {url: infoObj}; - } else if (infoObj === null) { + } else if (isNil(infoObj)) { return {url: ''}; } - infoObj.url = infoObj.url.replace(/^git\+/, ''); + infoObj.url = this.normalizeGitUrl(infoObj); return infoObj; } + normalizeGitUrl(infoObj) { + return infoObj.url.replace(/^git\+/, ''); + } + render() { const infos = this.infos; - if (!infos.homepage.url && !infos.repo.url && infos.license === 'N/A') { + if (infos.homepage.url === '' && infos.repo.url === '' && infos.license === 'N/A') { return ''; } @@ -43,13 +49,9 @@ export default class Infos extends React.Component { className={classes.infosModule} >