fix(mix): remove global flag in regex to match multiple organizations (#24091)

This commit is contained in:
Marcowindt 2023-08-26 07:11:24 +02:00 committed by GitHub
parent 36e9537f94
commit b8823e3deb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -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
@ -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' },
]);
});

View file

@ -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({