Fix replacing v prefix in tool version

This commit is contained in:
Shivam Mathur 2021-06-18 23:31:47 +05:30
parent dd591f1661
commit 60ff774608
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 2 additions and 6 deletions

4
dist/index.js vendored
View File

@ -497,10 +497,8 @@ const utils = __importStar(__nccwpck_require__(918));
async function getToolVersion(version) { async function getToolVersion(version) {
const semver_regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; const semver_regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/; const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, ''); version = version.replace(/[><=^]*/, '').replace(/^v(\d)/, '$1');
switch (true) { switch (true) {
case version.charAt(0) == 'v':
return version.replace('v', '');
case composer_regex.test(version): case composer_regex.test(version):
case semver_regex.test(version): case semver_regex.test(version):
return version; return version;

View File

@ -10,10 +10,8 @@ export async function getToolVersion(version: string): Promise<string> {
const semver_regex = const semver_regex =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/; const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, ''); version = version.replace(/[><=^]*/, '').replace(/^v(\d)/, '$1');
switch (true) { switch (true) {
case version.charAt(0) == 'v':
return version.replace('v', '');
case composer_regex.test(version): case composer_regex.test(version):
case semver_regex.test(version): case semver_regex.test(version):
return version; return version;