Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Remove letters from tags before doing a ParseUint(), preventing it from always returning 0 when tag contains letter (#1701)

* Update helpers.go

* Update helpers.go

* Update helpers.go

* Update helpers.go

* remove debug log
Cette révision appartient à :
kilo 2017-11-02 07:59:34 +01:00 révisé par GitHub
Parent 9fe0efa5fd
révision 7c7ce64ae5
Signature inconnue de Forgejo
ID de la clé GPG: 4AEE18F83AFDEB23
1 fichiers modifiés avec 12 ajouts et 1 suppressions

Voir le fichier

@ -125,7 +125,7 @@ func callbackOnType(tag *models.Tag, torrent *models.Torrent) {
// We finally add the tag to the column
torrent.AcceptedTags += tag.Tag
case "anidbid", "vndbid", "vgmdbid":
u64, _ := strconv.ParseUint(tag.Tag, 10, 32)
u64, _ := strconv.ParseUint(trimNonNumbers(tag.Tag), 10, 32)
// TODO: Perform a check that anidbid is in anidb database
tagConf := config.Get().Torrents.Tags.Types.Get(tag.Type)
reflect.ValueOf(torrent).Elem().FieldByName(tagConf.Field).SetUint(u64)
@ -155,3 +155,14 @@ func callbackOnType(tag *models.Tag, torrent *models.Torrent) {
}
}
}
func trimNonNumbers(source string) string {
output := ""
for i := 0; i < len(source); i++ {
if source[i] < 58 {
output += source[i:i+1]
}
}
return output
}