feat(dart): allow custom registryUrls (#25987)

This commit is contained in:
Rhys Arkins 2023-11-27 16:09:26 +01:00 committed by GitHub
parent 2bc920181b
commit c4bb98ab90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -3,7 +3,7 @@
exports[`modules/datasource/dart/index getReleases processes real data 1`] = ` exports[`modules/datasource/dart/index getReleases processes real data 1`] = `
{ {
"homepage": "https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences", "homepage": "https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences",
"registryUrl": "https://pub.dartlang.org/", "registryUrl": "https://pub.dartlang.org",
"releases": [ "releases": [
{ {
"releaseTimestamp": "2017-05-09T18:25:24.268Z", "releaseTimestamp": "2017-05-09T18:25:24.268Z",

View file

@ -1,4 +1,5 @@
import type { HttpResponse } from '../../../util/http/types'; import type { HttpResponse } from '../../../util/http/types';
import { ensureTrailingSlash } from '../../../util/url';
import { Datasource } from '../datasource'; import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { GetReleasesConfig, ReleaseResult } from '../types';
import type { DartResult } from './types'; import type { DartResult } from './types';
@ -10,7 +11,7 @@ export class DartDatasource extends Datasource {
super(DartDatasource.id); super(DartDatasource.id);
} }
override readonly customRegistrySupport = false; override readonly customRegistrySupport = true;
override readonly defaultRegistryUrls = ['https://pub.dartlang.org/']; override readonly defaultRegistryUrls = ['https://pub.dartlang.org/'];
@ -23,7 +24,9 @@ export class DartDatasource extends Datasource {
return null; return null;
} }
let result: ReleaseResult | null = null; let result: ReleaseResult | null = null;
const pkgUrl = `${registryUrl}api/packages/${packageName}`; const pkgUrl = `${ensureTrailingSlash(
registryUrl,
)}api/packages/${packageName}`;
let raw: HttpResponse<DartResult> | null = null; let raw: HttpResponse<DartResult> | null = null;
try { try {