Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/utils/search/maxtype.go

24 lignes
699 B
Go

package search
import (
"strconv"
"github.com/NyaaPantsu/nyaa/config"
)
type maxType uint32
// Parse the maximum number of result
func (m *maxType) Parse(s string) {
max, err := strconv.ParseUint(s, 10, 32)
if err != nil {
// If we can't convert the limit from url to int, we set it to default value
max = uint64(config.Get().Navigation.TorrentsPerPage)
} else if max > uint64(config.Get().Navigation.MaxTorrentsPerPage) {
// If the maximum value is greater than the maximum set in config.yml, we overwrite it with the configured one
// Stops someone to make an unthinkable query of max=huge number
max = uint64(config.Get().Navigation.MaxTorrentsPerPage)
}
*m = maxType(max)
}