* Normalize a version string for comparison. * Handles variations like "1.22" vs "1.22.0" by ensuring consistent format.
(version)
| 113 | * Handles variations like "1.22" vs "1.22.0" by ensuring consistent format. |
| 114 | */ |
| 115 | function 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) |
no outgoing calls
no test coverage detected