Skip to content
Snippets Groups Projects
Unverified Commit d6504273 authored by Sergio Zharinov's avatar Sergio Zharinov Committed by GitHub
Browse files

fix(composer): Remove leading `v` in comparison (#5396)

parent b636307c
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,12 @@ function padZeroes(input: string): string { ...@@ -11,8 +11,12 @@ function padZeroes(input: string): string {
return sections.join('.'); return sections.join('.');
} }
function removeLeadingV(input: string): string {
return input.replace(/^v/i, '');
}
function composer2npm(input: string): string { function composer2npm(input: string): string {
const cleanInput = input.replace(/^v/, ''); const cleanInput = removeLeadingV(input);
if (npm.isVersion(cleanInput)) { if (npm.isVersion(cleanInput)) {
return cleanInput; return cleanInput;
} }
...@@ -83,7 +87,7 @@ function getNewValue({ ...@@ -83,7 +87,7 @@ function getNewValue({
} else if ( } else if (
npm.isVersion(padZeroes(toVersion)) && npm.isVersion(padZeroes(toVersion)) &&
npm.isValid(currentValue) && npm.isValid(currentValue) &&
composer2npm(currentValue) === currentValue composer2npm(currentValue) === removeLeadingV(currentValue)
) { ) {
newValue = npm.getNewValue({ newValue = npm.getNewValue({
currentValue, currentValue,
......
...@@ -257,5 +257,14 @@ describe('semver.getNewValue()', () => { ...@@ -257,5 +257,14 @@ describe('semver.getNewValue()', () => {
toVersion: '3.7', toVersion: '3.7',
}) })
).toEqual('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
}); });
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment