diff --git a/src/components/content/gitcontent/gitcontent.js b/src/components/content/gitcontent/gitcontent.js index 179f8e4..0e0bfdd 100644 --- a/src/components/content/gitcontent/gitcontent.js +++ b/src/components/content/gitcontent/gitcontent.js @@ -17,8 +17,8 @@ class GitContent extends PureComponent { { const query = qs.parse(location.search); - console.log(query); - if ((query['?p'] || query.p) || (location.pathname !== '/' && location.pathname !== '')) { + const pathname = query['?p'] || query.p; + if ((pathname && pathname !== '/') || (location.pathname !== '/' && location.pathname !== '')) { return ; } return ; diff --git a/src/components/content/gitcontent/readme/index.js b/src/components/content/gitcontent/readme/index.js index 0bbf0f5..a48bb2a 100644 --- a/src/components/content/gitcontent/readme/index.js +++ b/src/components/content/gitcontent/readme/index.js @@ -24,11 +24,8 @@ class ReadMeContainer extends PureComponent { const query = qs.parse(this.props.location.search); if (query['?p'] || query.p) { const pathname = query['?p'] || query.p; - if (pathname.startsWith('/')) { - this._getReadMe(pathname); - } else { - this._getReadMe(`/${pathname}`); - } + const packageName = pathname.startsWith('/') ? pathname.substr(1, pathname.length) : pathname; + this._getReadMe(packageName); } else { this._getReadMe(this.props.location.pathname); } @@ -36,7 +33,7 @@ class ReadMeContainer extends PureComponent { componentWillReceiveProps(nextProps : Props) { if (nextProps.location.pathname && this.props.location.pathname !== nextProps.location.pathname) { - this._getReadMe(this.props.location.pathname); + this._getReadMe(nextProps.location.pathname); } }