@@ -11,7 +11,7 @@ type PreRelease =
11
11
Number : int option }
12
12
13
13
static member TryParse str =
14
- let m = Regex( " ^(?<name>[a-zA-Z]+)(?<number>\d *)$" ) .Match( str)
14
+ let m = Regex( " ^(?<name>[a-zA-Z- ]+)(?<number>\d *)$" ) .Match( str)
15
15
match m.Success, m.Groups.[ " name" ]. Value, m.Groups.[ " number" ]. Value with
16
16
| true , name, " " ->
17
17
Some { Origin = str
@@ -109,25 +109,24 @@ module SemVer =
109
109
let Parse ( version : string ) =
110
110
let splitted = version.Split '.'
111
111
let l = splitted.Length
112
-
112
+
113
+ let splitAtFirst ( char : char ) ( s : string )=
114
+ match s.IndexOf( char) with
115
+ | - 1 -> s, " "
116
+ | x -> s.Substring( 0 , x), s.Substring( x+ 1 )
117
+
113
118
let patch , preRelease =
114
119
match l with
115
120
| 0 -> 0 , " "
116
121
| 1 ->
117
- let splitted ' = splitted.[ 0 ]. Split '-'
118
- 0 ,
119
- if splitted'.Length > 1 then splitted'.[ 1 ]
120
- else " "
122
+ let _ , splitted' = splitted.[ 0 ] |> splitAtFirst '-'
123
+ 0 , splitted'
121
124
| 2 ->
122
- let splitted ' = splitted.[ 1 ]. Split '-'
123
- 0 ,
124
- if splitted'.Length > 1 then splitted'.[ 1 ]
125
- else " "
125
+ let _ , splitted' = splitted.[ 1 ] |> splitAtFirst '-'
126
+ 0 , splitted'
126
127
| _ ->
127
- let splitted ' = splitted.[ 2 ]. Split '-'
128
- Int32.Parse splitted'.[ 0 ],
129
- if splitted'.Length > 1 then splitted'.[ 1 ]
130
- else " "
128
+ let p , splitted' = splitted.[ 2 ] |> splitAtFirst '-'
129
+ Int32.Parse p, splitted'
131
130
{ Major =
132
131
if l > 0 then Int32.Parse ( splitted.[ 0 ]. Split( '-' ).[ 0 ])
133
132
else 0
0 commit comments