MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / normalizeVersion

Function normalizeVersion

scripts/check-sdk-version-sync.mjs:127–140  ·  view source on GitHub ↗

* Normalize a version string for comparison. * Handles variations like "1.22" vs "1.22.0" by ensuring consistent format.

(version)

Source from the content-addressed store, hash-verified

125 * Handles variations like "1.22" vs "1.22.0" by ensuring consistent format.
126 */
127function normalizeVersion(version) {
128 if (!version) return null;
129
130 // Remove any pre-release or build metadata for base comparison
131 const baseVersion = version.split(/[-+]/)[0];
132
133 // Split into parts and pad to 3 parts (major.minor.patch)
134 const parts = baseVersion.split(".").map((p) => parseInt(p, 10) || 0);
135 while (parts.length < 3) {
136 parts.push(0);
137 }
138
139 return parts.slice(0, 3).join(".");
140}
141
142/**
143 * Compare two versions for equality (handles semantic equivalence)

Callers 2

versionsEqualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected