Repository navigation
Commit 5e72e93
feat(shared): support shorthand (major-only) versions in the semver helpers
`normalizeSemverVersion` padded a two-segment version ("2.1" -> "2.1.0") but
left a bare major ("20") untouched, so `parseSemver("20")` returned null and
`compareSemverVersions` fell back to lexical string comparison —
`compareSemverVersions("20", "9")` returned a negative number, i.e. it ordered
20 before 9. The sibling `satisfiesSemverRange` in the same module already
accepts shorthand versions (its regex defaults a missing minor/patch to 0), so
the helpers disagreed on what a valid version was.
Pad any 1- or 2-segment version up to three segments so major-only and
minor-only inputs parse and compare numerically, making the module
self-consistent. Empty/garbage input stays empty (`parseSemver` still rejects
it) and inputs with more than three segments are untouched. Existing full x.y.z
callers are unaffected and simply become robust to a shorthand version report.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>1 parent e482960 commit 5e72e93
2 files changed
Lines changed: 31 additions & 2 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
21 | 45 | | |
22 | 46 | | |
23 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
0 commit comments