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

Function normalizeVersion

scripts/check-sdk-version-sync.mjs:115–128  ·  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

113 * Handles variations like "1.22" vs "1.22.0" by ensuring consistent format.
114 */
115function normalizeVersion(version) {
116 if (!version) return null;
117
118 // Remove any pre-release or build metadata for base comparison
119 const baseVersion = version.split(/[-+]/)[0];
120
121 // Split into parts and pad to 3 parts (major.minor.patch)
122 const parts = baseVersion.split(".").map((p) => parseInt(p, 10) || 0);
123 while (parts.length < 3) {
124 parts.push(0);
125 }
126
127 return parts.slice(0, 3).join(".");
128}
129
130/**
131 * Compare two versions for equality (handles semantic equivalence)

Callers 2

versionsEqualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected