Skip to content

Commit

Permalink
fix(datasource/hex): allow custom registries (#29534)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jun 8, 2024
1 parent 6749322 commit 4354dd9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`modules/datasource/hex/index getReleases process public repo without auth 1`] = `
{
"homepage": "https://hex.pm/packages/certifi",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"isDeprecated": true,
Expand Down Expand Up @@ -93,7 +93,7 @@ exports[`modules/datasource/hex/index getReleases process public repo without au
exports[`modules/datasource/hex/index getReleases processes a private repo with auth 1`] = `
{
"homepage": "https://hex.pm/packages/renovate_test/private_package",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"releaseTimestamp": "2021-08-04T15:26:26.500Z",
Expand All @@ -110,7 +110,7 @@ exports[`modules/datasource/hex/index getReleases processes a private repo with
exports[`modules/datasource/hex/index getReleases processes real data 1`] = `
{
"homepage": "https://hex.pm/packages/certifi",
"registryUrl": "https://hex.pm/",
"registryUrl": "https://hex.pm",
"releases": [
{
"isDeprecated": true,
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/hex/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('modules/datasource/hex/index', () => {

expect(result).toEqual({
homepage: 'https://hex.pm/packages/renovate_test/private_package',
registryUrl: 'https://hex.pm/',
registryUrl: 'https://hex.pm',
releases: [
{ releaseTimestamp: '2021-08-04T15:26:26.500Z', version: '0.1.0' },
{ releaseTimestamp: '2021-08-04T17:46:00.274Z', version: '0.1.1' },
Expand Down
11 changes: 7 additions & 4 deletions lib/modules/datasource/hex/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { joinUrlParts } from '../../../util/url';
import * as hexVersioning from '../../versioning/hex';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
Expand All @@ -12,9 +13,7 @@ export class HexDatasource extends Datasource {
super(HexDatasource.id);
}

override readonly defaultRegistryUrls = ['https://hex.pm/'];

override readonly customRegistrySupport = false;
override readonly defaultRegistryUrls = ['https://hex.pm'];

override readonly defaultVersioning = hexVersioning.id;

Expand Down Expand Up @@ -47,7 +46,11 @@ export class HexDatasource extends Datasource {
const organizationUrlPrefix = organizationName
? `repos/${organizationName}/`
: '';
const hexUrl = `${registryUrl}api/${organizationUrlPrefix}packages/${hexPackageName}`;

const hexUrl = joinUrlParts(
registryUrl,
`/api/${organizationUrlPrefix}packages/${hexPackageName}`,
);

const { val: result, err } = await this.http
.getJsonSafe(hexUrl, HexRelease)
Expand Down

0 comments on commit 4354dd9

Please sign in to comment.