Skip to content

Commit

Permalink
fix(semver-coerced): only coerce if not a valid semver version (#27384)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 18, 2024
1 parent f423aa5 commit 7b7a0b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/modules/versioning/semver-coerced/index.spec.ts
Expand Up @@ -231,7 +231,7 @@ describe('modules/versioning/semver-coerced/index', () => {
it('should support coercion', () => {
expect(
semverCoerced.getSatisfyingVersion(['v1.0', '1.0.4-foo'], '^1.0'),
).toBe('1.0.4');
).toBe('1.0.0');
});
});

Expand Down
4 changes: 3 additions & 1 deletion lib/modules/versioning/semver-coerced/index.ts
Expand Up @@ -71,7 +71,9 @@ function getSatisfyingVersion(
range: string,
): string | null {
const coercedVersions = versions
.map((version) => semver.coerce(version)?.version)
.map((version) =>
semver.valid(version) ? version : semver.coerce(version)?.version,
)
.filter(is.string);

return semver.maxSatisfying(coercedVersions, range);
Expand Down

0 comments on commit 7b7a0b1

Please sign in to comment.