diff --git a/lib/pool.go b/lib/pool.go index f06b4ec..f50e4aa 100644 --- a/lib/pool.go +++ b/lib/pool.go @@ -8,6 +8,8 @@ import ( "io" "os" "path" + "strings" + "unicode" "github.com/bigkevmcd/go-configparser" ) @@ -25,6 +27,21 @@ type Pool struct { Dir string `json:"dir"` } +func (p *Pool) ID() string { + var res string = "" + + for _, c := range p.Display { + if unicode.IsDigit(c) || unicode.IsLetter(c) { + res += string(c) + continue + } + + res += "-" + } + + return strings.TrimSuffix(res, "-") +} + func (p *Pool) Load(list *[]Package) error { var err error diff --git a/routes/package.go b/routes/package.go index 8a29cd8..9dc9889 100644 --- a/routes/package.go +++ b/routes/package.go @@ -12,6 +12,7 @@ func GET_package(c *fiber.Ctx) error { var ( name string version string + pool string list *[]lib.Package ) @@ -21,11 +22,11 @@ func GET_package(c *fiber.Ctx) error { list = c.Locals("list").(*[]lib.Package) version = c.Params("version") name = c.Params("name") + pool = c.Query("p") for _, pkg := range *list { - if pkg.Name != name || (version != "ANY" && pkg.Version != version) { + if pkg.Name != name || (version != "ANY" && pkg.Version != version) || (pool != "" && pkg.Pool.ID() != pool) { continue - } if is_download { diff --git a/templates/index.html b/templates/index.html index 430dbf5..13f3c72 100644 --- a/templates/index.html +++ b/templates/index.html @@ -49,7 +49,7 @@ {{range .list}}