From c4bb98ab90e8b90fa9263bea7ecd322d9de2db61 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Mon, 27 Nov 2023 16:09:26 +0100 Subject: [PATCH] feat(dart): allow custom registryUrls (#25987) --- .../datasource/dart/__snapshots__/index.spec.ts.snap | 2 +- lib/modules/datasource/dart/index.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/modules/datasource/dart/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/dart/__snapshots__/index.spec.ts.snap index 63f14b0018..f3a5181107 100644 --- a/lib/modules/datasource/dart/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/dart/__snapshots__/index.spec.ts.snap @@ -3,7 +3,7 @@ exports[`modules/datasource/dart/index getReleases processes real data 1`] = ` { "homepage": "https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences", - "registryUrl": "https://pub.dartlang.org/", + "registryUrl": "https://pub.dartlang.org", "releases": [ { "releaseTimestamp": "2017-05-09T18:25:24.268Z", diff --git a/lib/modules/datasource/dart/index.ts b/lib/modules/datasource/dart/index.ts index f3069a9382..30da6a53c2 100644 --- a/lib/modules/datasource/dart/index.ts +++ b/lib/modules/datasource/dart/index.ts @@ -1,4 +1,5 @@ import type { HttpResponse } from '../../../util/http/types'; +import { ensureTrailingSlash } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { DartResult } from './types'; @@ -10,7 +11,7 @@ export class DartDatasource extends Datasource { super(DartDatasource.id); } - override readonly customRegistrySupport = false; + override readonly customRegistrySupport = true; override readonly defaultRegistryUrls = ['https://pub.dartlang.org/']; @@ -23,7 +24,9 @@ export class DartDatasource extends Datasource { return null; } let result: ReleaseResult | null = null; - const pkgUrl = `${registryUrl}api/packages/${packageName}`; + const pkgUrl = `${ensureTrailingSlash( + registryUrl, + )}api/packages/${packageName}`; let raw: HttpResponse | null = null; try {