diff --git a/dist/index.js b/dist/index.js index 0f6585b..26a2787 100644 --- a/dist/index.js +++ b/dist/index.js @@ -26067,9 +26067,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) { ) } +const knownBranches = ['main', 'master', 'maint'] +const nonSpecificVersions = ['nightly', 'latest'] + async function getElixirVersion(exSpec0, otpVersion0) { const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1] - let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$` + let otpVersionMajor = otpVersion.match(new RegExp(regex))[1] const otpSuffix = /-otp-(\d+)/ const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null @@ -26316,7 +26320,9 @@ function gt(left, right) { function validVersion(v) { return ( - v.match(/main|master|nightly|latest/g) == null && + v.match( + new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), + ) == null && !v.startsWith('a') && !v.startsWith('b') ) @@ -26435,8 +26441,6 @@ function isRC(ver) { return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) } -const knownBranches = ['main', 'master', 'maint'] - function isKnownBranch(ver) { return knownBranches.includes(ver) } diff --git a/src/setup-beam.js b/src/setup-beam.js index 926e0c5..af3961c 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -192,9 +192,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) { ) } +const knownBranches = ['main', 'master', 'maint'] +const nonSpecificVersions = ['nightly', 'latest'] + async function getElixirVersion(exSpec0, otpVersion0) { const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1] - let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$` + let otpVersionMajor = otpVersion.match(new RegExp(regex))[1] const otpSuffix = /-otp-(\d+)/ const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null @@ -441,7 +445,9 @@ function gt(left, right) { function validVersion(v) { return ( - v.match(/main|master|nightly|latest/g) == null && + v.match( + new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), + ) == null && !v.startsWith('a') && !v.startsWith('b') ) @@ -560,8 +566,6 @@ function isRC(ver) { return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) } -const knownBranches = ['main', 'master', 'maint'] - function isKnownBranch(ver) { return knownBranches.includes(ver) }