Keep a two digit minor in parseVersion (#1134)

Co-authored-by: Michael Lip <51033404+theluckystrike@users.noreply.github.com>
This commit is contained in:
Michael Lip
2026-10-10 15:23:58 +05:30
committed by GitHub
parent db75472672
commit c463b1d02f
3 changed files with 7 additions and 7 deletions
+3
View File
@@ -58,6 +58,9 @@ describe('Utils tests', () => {
expect(await utils.parseVersion('8.7.0')).toBe('8.7');
expect(await utils.parseVersion('7')).toBe('7.0');
expect(await utils.parseVersion('7.4')).toBe('7.4');
expect(await utils.parseVersion('8.10')).toBe('8.10');
expect(await utils.parseVersion('10')).toBe('10.0');
expect(await utils.parseVersion('10.0')).toBe('10.0');
expect(await utils.parseVersion('5.x')).toBe('5.6');
expect(await utils.parseVersion('pre')).toBe('pre');
expect(await utils.parseVersion('pre-installed')).toBe('pre');
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -6
View File
@@ -91,12 +91,9 @@ export async function parseVersion(version: string): Promise<string> {
if (!/^\d+(\.\d+){0,2}$/.test(version)) {
throw new Error(`Invalid PHP version: ${version.slice(0, 20)}`);
}
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
return version.includes('.')
? version.split('.').slice(0, 2).join('.')
: version + '.0';
}
}