diff --git a/lib/versioning/composer/index.ts b/lib/versioning/composer/index.ts index 721c58515ff7de27c7a7b93ccb7980529ae9ff16..d1f7b686d3301e466902402b5de8c025bcc6b741 100644 --- a/lib/versioning/composer/index.ts +++ b/lib/versioning/composer/index.ts @@ -11,8 +11,12 @@ function padZeroes(input: string): string { return sections.join('.'); } +function removeLeadingV(input: string): string { + return input.replace(/^v/i, ''); +} + function composer2npm(input: string): string { - const cleanInput = input.replace(/^v/, ''); + const cleanInput = removeLeadingV(input); if (npm.isVersion(cleanInput)) { return cleanInput; } @@ -83,7 +87,7 @@ function getNewValue({ } else if ( npm.isVersion(padZeroes(toVersion)) && npm.isValid(currentValue) && - composer2npm(currentValue) === currentValue + composer2npm(currentValue) === removeLeadingV(currentValue) ) { newValue = npm.getNewValue({ currentValue, diff --git a/test/versioning/composer.spec.ts b/test/versioning/composer.spec.ts index 4496b70b6f2431a2e5ce371fdbf90ba84b1cb204..6097d526b4fad4f07af6f6d1c9b2c7662f649004 100644 --- a/test/versioning/composer.spec.ts +++ b/test/versioning/composer.spec.ts @@ -257,5 +257,14 @@ describe('semver.getNewValue()', () => { toVersion: '3.7', }) ).toEqual('3.7.*'); + + expect( + semver.getNewValue({ + currentValue: 'v3.1.*', + rangeStrategy: 'replace', + fromVersion: '3.1.10', + toVersion: '3.2.0', + }) + ).toEqual('v3.2.*'); // #5388 }); });