Skip to content

Commit

Permalink
fix(mix): remove global flag in regex to match multiple organizations (
Browse files Browse the repository at this point in the history
  • Loading branch information
marcowindt authored Aug 26, 2023
1 parent 36e9537 commit b8823e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/modules/manager/mix/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,14 @@ describe('modules/manager/mix/artifacts', () => {
hostRules.getAll.mockReturnValueOnce([
{ matchHost: 'https://hex.pm/api/repos/an_organization/' },
{ matchHost: 'https://hex.pm/api/repos/unauthorized_organization/' },
{ matchHost: 'https://hex.pm/api/repos/other_organization/' },
{ matchHost: 'https://hex.pm/api/repos/does_not_match_org/packages/' },
{ matchHost: 'https://example.com/api/repos/also_does_not_match_org/' },
{ matchHost: 'hex.pm' },
]);
hostRules.find.mockReturnValueOnce({ token: 'an_organization_token' });
hostRules.find.mockReturnValueOnce({}); // unauthorized_organization token missing
hostRules.find.mockReturnValueOnce({ token: 'other_org_token' });
hostRules.find.mockReturnValueOnce({ token: 'does_not_match_org_token' });

// erlang
Expand Down Expand Up @@ -283,6 +285,9 @@ describe('modules/manager/mix/artifacts', () => {
{
cmd: 'mix hex.organization auth an_organization --key an_organization_token',
},
{
cmd: 'mix hex.organization auth other_organization --key other_org_token',
},
{ cmd: 'mix deps.update some_package' },
]);
});
Expand Down
3 changes: 1 addition & 2 deletions lib/modules/manager/mix/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import type { UpdateArtifact, UpdateArtifactsResult } from '../types';

const hexRepoUrl = 'https://hex.pm/';
const hexRepoOrgUrlRegex = regEx(
`https://hex\\.pm/api/repos/(?<organization>[a-z0-9_]+)/$`,
'g'
`^https://hex\\.pm/api/repos/(?<organization>[a-z0-9_]+)/$`
);

export async function updateArtifacts({
Expand Down

0 comments on commit b8823e3

Please sign in to comment.