From f710c81b64db4f52bf76c2ff0e96a623dbb27cb0 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Wed, 5 May 2021 09:32:03 +0200
Subject: [PATCH] fix: check urls are string before trimming

---
 lib/datasource/metadata.ts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts
index 41e014cba2..7aef15c547 100644
--- a/lib/datasource/metadata.ts
+++ b/lib/datasource/metadata.ts
@@ -4,6 +4,7 @@ import { DateTime } from 'luxon';
 import * as hostRules from '../util/host-rules';
 import { validateUrl } from '../util/url';
 import type { ReleaseResult } from './types';
+import is from '@sindresorhus/is';
 
 // Use this object to define changelog URLs for packages
 // Only necessary when the changelog data cannot be found in the package's source repository
@@ -231,7 +232,7 @@ export function addMetaData(
   // Clean up any empty urls
   const urls = ['homepage', 'sourceUrl', 'changelogUrl', 'dependencyUrl'];
   for (const url of urls) {
-    if (validateUrl(dep[url]?.trim())) {
+    if (is.string(dep[url]) && validateUrl(dep[url].trim())) {
       dep[url] = dep[url].trim();
     } else {
       delete dep[url];
-- 
GitLab