diff --git a/lib/modules/datasource/github-releases/cache/cache-base.ts b/lib/modules/datasource/github-releases/cache/cache-base.ts
index 11b2797a8d4c5d11cdaa7901931f272fba7abac7..90c80a18ea3ac7d95921ba187f07d51db055e984 100644
--- a/lib/modules/datasource/github-releases/cache/cache-base.ts
+++ b/lib/modules/datasource/github-releases/cache/cache-base.ts
@@ -181,7 +181,7 @@ export abstract class AbstractGithubDatasourceCache<
     // so that soft update mechanics is immediately starting.
     let cacheUpdatedAt = now.minus(this.updateDuration).toISO();
 
-    const baseUrl = getApiBaseUrl(registryUrl).replace('/v3/', '/'); // Replace for GHE
+    const baseUrl = getApiBaseUrl(registryUrl).replace(/\/v3\/$/, '/'); // Replace for GHE
 
     const [owner, name] = packageName.split('/');
     if (owner && name) {
diff --git a/lib/modules/datasource/github-releases/common.spec.ts b/lib/modules/datasource/github-releases/common.spec.ts
index e386f33750a804eb9dd564498d52eb902d5a8a60..ebcaffcbbf9bd98acfa568691e5ba05765b4d2c3 100644
--- a/lib/modules/datasource/github-releases/common.spec.ts
+++ b/lib/modules/datasource/github-releases/common.spec.ts
@@ -20,8 +20,12 @@ describe('modules/datasource/github-releases/common', () => {
     });
 
     it('supports local github installations', () => {
-      const apiUrl = getApiBaseUrl('https://gh.my-company.com/');
-      expect(apiUrl).toBe('https://gh.my-company.com/api/v3/');
+      expect(getApiBaseUrl('https://gh.my-company.com/')).toBe(
+        'https://gh.my-company.com/api/v3/'
+      );
+      expect(getApiBaseUrl('https://gh.my-company.com/api/v3/')).toBe(
+        'https://gh.my-company.com/api/v3/'
+      );
     });
   });
 });
diff --git a/lib/modules/datasource/github-releases/common.ts b/lib/modules/datasource/github-releases/common.ts
index 638ebdeff5f7a1cc4cd2e328557a3a60ca600940..58969644bda5ef648c86f5f0800d2e31a7b9f81b 100644
--- a/lib/modules/datasource/github-releases/common.ts
+++ b/lib/modules/datasource/github-releases/common.ts
@@ -10,9 +10,19 @@ export function getSourceUrlBase(registryUrl: string | undefined): string {
 
 export function getApiBaseUrl(registryUrl: string | undefined): string {
   const sourceUrlBase = getSourceUrlBase(registryUrl);
-  return [defaultSourceUrlBase, defaultApiBaseUrl].includes(sourceUrlBase)
-    ? defaultApiBaseUrl
-    : `${sourceUrlBase}api/v3/`;
+
+  if (
+    sourceUrlBase === defaultSourceUrlBase ||
+    sourceUrlBase === defaultApiBaseUrl
+  ) {
+    return defaultApiBaseUrl;
+  }
+
+  if (sourceUrlBase.endsWith('/api/v3/')) {
+    return sourceUrlBase;
+  }
+
+  return `${sourceUrlBase}api/v3/`;
 }
 
 export function getSourceUrl(