fix: check if defined before includes

This commit is contained in:
Rhys Arkins 2020-05-28 14:09:28 +02:00
parent bb7e8b97c1
commit 4b59bedaae

View file

@ -114,14 +114,13 @@ export function addMetaData(
}; };
if ( if (
dep.changelogUrl && dep.changelogUrl?.includes('github.com') && // lgtm [js/incomplete-url-substring-sanitization]
dep.changelogUrl.includes('github.com') && // lgtm [js/incomplete-url-substring-sanitization]
!dep.sourceUrl !dep.sourceUrl
) { ) {
dep.sourceUrl = dep.changelogUrl; dep.sourceUrl = dep.changelogUrl;
} }
// prettier-ignore // prettier-ignore
if (dep.homepage && dep.homepage.includes('github.com')) { // lgtm [js/incomplete-url-substring-sanitization] if (dep.homepage?.includes('github.com')) { // lgtm [js/incomplete-url-substring-sanitization]
if (!dep.sourceUrl) { if (!dep.sourceUrl) {
dep.sourceUrl = dep.homepage; dep.sourceUrl = dep.homepage;
} }
@ -134,7 +133,7 @@ export function addMetaData(
}); });
extraBaseUrls.push('gitlab.com'); extraBaseUrls.push('gitlab.com');
if (dep.sourceUrl) { if (dep.sourceUrl) {
if (URL.parse(dep.sourceUrl).hostname.includes('gitlab')) { if (URL.parse(dep.sourceUrl).hostname?.includes('gitlab')) {
// try massaging it // try massaging it
dep.sourceUrl = dep.sourceUrl =
parse(massageGitlabUrl(dep.sourceUrl), { parse(massageGitlabUrl(dep.sourceUrl), {