Ver a proveniência

Revert "Send nice error when version number is out of range"

This reverts commit f4151cb744.
master
GeertJohan há 10 anos
ascendente
cometimento
d25e20e4a7
2 ficheiros alterados com 4 adições e 12 eliminações
  1. +0
    -4
      main.go
  2. +4
    -8
      version.go

+ 0
- 4
main.go Ver ficheiro

@@ -138,10 +138,6 @@ func handler(resp http.ResponseWriter, req *http.Request) {
var ok bool var ok bool
repo.Version, ok = parseVersion(m[3]) repo.Version, ok = parseVersion(m[3])
if !ok { if !ok {
if repo.Version == TooHighVersion {
sendNotFound(resp, "Version %q contains a number which is out of range.", m[3])
return
}
sendNotFound(resp, "Version %q improperly considered invalid; please warn the service maintainers.", m[3]) sendNotFound(resp, "Version %q improperly considered invalid; please warn the service maintainers.", m[3])
return return
} }


+ 4
- 8
version.go Ver ficheiro

@@ -48,7 +48,6 @@ func (v Version) IsValid() bool {
} }


var InvalidVersion = Version{-1, -1, -1} var InvalidVersion = Version{-1, -1, -1}
var TooHighVersion = Version{-2, -2, -2}


func parseVersion(s string) (Version, bool) { func parseVersion(s string) (Version, bool) {
if len(s) < 2 { if len(s) < 2 {
@@ -67,20 +66,17 @@ func parseVersion(s string) (Version, bool) {
if len(part) == 0 || part[0] == '0' { if len(part) == 0 || part[0] == '0' {
return InvalidVersion, false return InvalidVersion, false
} }
num, err := strconv.ParseInt(part, 10, 32)
num, err := strconv.Atoi(part)
if err != nil { if err != nil {
if err.(*strconv.NumError).Err == strconv.ErrRange {
return TooHighVersion, false
}
return InvalidVersion, false return InvalidVersion, false
} }
switch i { switch i {
case 0: case 0:
v.Major = int(num)
v.Major = num
case 1: case 1:
v.Minor = int(num)
v.Minor = num
case 2: case 2:
v.Patch = int(num)
v.Patch = num
} }
} }




Carregando…
Cancelar
Guardar