doc: fix bad numeric version for irssi, add clientTag test
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
e9ad8f6962
commit
19e0120423
12
clientTag.go
12
clientTag.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -9,6 +10,10 @@ type clientTag struct {
|
||||
Version string
|
||||
}
|
||||
|
||||
var (
|
||||
rx_bestNumberPart = regexp.MustCompile(`[0-9\.]+`)
|
||||
)
|
||||
|
||||
func parseVersion(ver string) clientTag {
|
||||
// Try our best to turn the supplied text into a structured version
|
||||
ret := clientTag{
|
||||
@ -39,9 +44,10 @@ func parseVersion(ver string) clientTag {
|
||||
}
|
||||
}
|
||||
|
||||
// Strip leading v from mIRC
|
||||
if len(ret.Version) >= 2 && (ret.Version[0] == 'v' || ret.Version[0] == 'V') && strings.ContainsAny(string(ret.Version[1]), "0123456789") {
|
||||
ret.Version = ret.Version[1:]
|
||||
// We only support digits, periods, and hyphens in the number part
|
||||
// This removes the leading v from mIRC and the trailing deb** from irssi
|
||||
if submatch := rx_bestNumberPart.FindStringSubmatch(ret.Version); len(submatch) == 1 {
|
||||
ret.Version = submatch[0]
|
||||
}
|
||||
|
||||
// Special case: "Relay" means "HoloIRC"
|
||||
|
@ -47,6 +47,11 @@ func TestParseVersion(t *testing.T) {
|
||||
"Revolution IRC:0.3.2:Android",
|
||||
"Revolution IRC", "0.3.2",
|
||||
},
|
||||
|
||||
[3]string{
|
||||
"irssi v1.0.2-1+deb9u3",
|
||||
"irssi", "1.0.2",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user