Match only on what we know should match (versions start with numbers, after OTP-) (#341)

This commit is contained in:
Paulo F. Oliveira
2025-05-30 05:43:43 +01:00
committed by GitHub
parent db4b4ce7c5
commit afe592256a
2 changed files with 16 additions and 8 deletions
+8 -4
View File
@@ -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)
}