fix(web): anchor patch agent version regex to mirror server parseVersion
This commit is contained in:
@@ -35,15 +35,17 @@ export const SERVER_STATUS: Record<PatchServerStatus, { label: string; variant:
|
||||
*/
|
||||
export const MIN_AGENT_VERSION = "1.4.0";
|
||||
|
||||
/** Mirrors patchrun.AgentSupportsPatchResults (and its parseVersion) in the server. */
|
||||
export function agentSupportsPatchResults(version?: string): boolean {
|
||||
const m = /^v?(\d+)\.(\d+)\.(\d+)(-[^+]+)?/.exec((version ?? "").trim());
|
||||
const m = /^v?(\d+)\.(\d+)\.(\d+)(?:-([^+]*))?(?:\+.*)?$/.exec((version ?? "").trim());
|
||||
if (!m) return false;
|
||||
const have = [Number(m[1]), Number(m[2]), Number(m[3])];
|
||||
const want = MIN_AGENT_VERSION.split(".").map(Number);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (have[i] !== want[i]) return have[i] > want[i];
|
||||
}
|
||||
return !m[4];
|
||||
const hasPrerelease = !!m[4];
|
||||
return !hasPrerelease;
|
||||
}
|
||||
|
||||
const DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
||||
|
||||
Reference in New Issue
Block a user