From 31ba0a579385b2a441978d91cf6e6f4773f0e9dd Mon Sep 17 00:00:00 2001 From: Rhys Arkins 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 41e014cba2961a..7aef15c5472ddb 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];