diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts
index 67e0b4312c0522dd212966f47d1734e7cb8acf85..bb8a2ccc4bd10421b7bc4827f5f10667fcac68b1 100644
--- a/lib/datasource/metadata.ts
+++ b/lib/datasource/metadata.ts
@@ -114,14 +114,13 @@ export function addMetaData(
   };
 
   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.changelogUrl;
   }
   // 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) {
       dep.sourceUrl = dep.homepage;
     }
@@ -134,7 +133,7 @@ export function addMetaData(
   });
   extraBaseUrls.push('gitlab.com');
   if (dep.sourceUrl) {
-    if (URL.parse(dep.sourceUrl).hostname.includes('gitlab')) {
+    if (URL.parse(dep.sourceUrl).hostname?.includes('gitlab')) {
       // try massaging it
       dep.sourceUrl =
         parse(massageGitlabUrl(dep.sourceUrl), {