Skip to content

Commit

Permalink
fix(versioning/pep440): match function should match on equality (#31170)
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor authored Sep 3, 2024
1 parent 9385d48 commit d0a6f28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/modules/versioning/pep440/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('modules/versioning/pep440/index', () => {
it.each`
a | b | expected
${'1.0'} | ${'>=1.0.0'} | ${true}
${'3.0.0'} | ${'3.0.0'} | ${true}
${'1.6.2'} | ${'<2.2.1.0'} | ${true}
${'>=3.8'} | ${'>=3.9'} | ${false}
`('matches($a, $b) === $expected', ({ a, b, expected }) => {
Expand Down
8 changes: 7 additions & 1 deletion lib/modules/versioning/pep440/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ const equals = (version1: string, version2: string): boolean =>
isVersion(version1) && isVersion(version2) && eq(version1, version2);

function matches(version: string, range: string): boolean {
return isVersion(version) && isValid(range) && satisfies(version, range);
if (!isVersion(version)) {
return false;
}
if (isVersion(range)) {
return equals(version, range);
}
return isValid(range) && satisfies(version, range);
}

export const api: VersioningApi = {
Expand Down

0 comments on commit d0a6f28

Please sign in to comment.