Skip to content

Commit

Permalink
Don’t parse eg. 5.2-start as 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 19, 2022
1 parent 9e874bf commit 033232c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/semver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class SemVer {
minor: number
patch: number

//FIXME
//FIXME parse these
readonly prerelease: string[] = []
readonly build: string[] = []

Expand All @@ -34,10 +34,12 @@ export default class SemVer {
if (isNaN(n)) throw new Error(`invalid version: ${input}`)
pretty_is_raw = true
return [n, char_to_num(match[2])]
} else {
const n = parseInt(x)
} else if (/^\d+$/.test(x)) {
const n = parseInt(x) // parseInt will parse eg. `5-start` to `5`
if (isNaN(n)) throw new Error(`invalid version: ${input}`)
return [n]
} else {
throw new Error(`invalid version: ${input}`)
}
})
this.raw = input
Expand Down

0 comments on commit 033232c

Please sign in to comment.