From 3a460c212a920936b2f001faf5f756f0cb6d13cf Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Fri, 5 Nov 2021 13:25:15 +0300
Subject: [PATCH] refactor(bitbucket): Extract getSourceUrl function (#12512)

---
 lib/datasource/bitbucket-tags/index.ts | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/datasource/bitbucket-tags/index.ts b/lib/datasource/bitbucket-tags/index.ts
index 59b98e44ab..53fe34d340 100644
--- a/lib/datasource/bitbucket-tags/index.ts
+++ b/lib/datasource/bitbucket-tags/index.ts
@@ -34,6 +34,12 @@ export class BitBucketTagsDatasource extends Datasource {
     )}:${repo}:${type}`;
   }
 
+  static getSourceUrl(lookupName: string, registryUrl?: string): string {
+    const url = BitBucketTagsDatasource.getRegistryURL(registryUrl);
+    const normalizedUrl = ensureTrailingSlash(url);
+    return `${normalizedUrl}${lookupName}`;
+  }
+
   // getReleases fetches list of tags for the repository
   @cache({
     namespace: BitBucketTagsDatasource.cacheNamespace,
@@ -51,9 +57,7 @@ export class BitBucketTagsDatasource extends Datasource {
     ).body;
 
     const dependency: ReleaseResult = {
-      sourceUrl: `${ensureTrailingSlash(
-        BitBucketTagsDatasource.getRegistryURL(registryUrl)
-      )}${repo}`,
+      sourceUrl: BitBucketTagsDatasource.getSourceUrl(repo, registryUrl),
       registryUrl: BitBucketTagsDatasource.getRegistryURL(registryUrl),
       releases: null,
     };
-- 
GitLab