From 185e20a6ab9c8746ec8c386ab7d755be6afc709c Mon Sep 17 00:00:00 2001 From: Ruben Gees Date: Sat, 25 Sep 2021 15:36:06 +0200 Subject: [PATCH] Filter empty version on single version query --- src/strategy/organization-strategy.js | 4 +++- src/strategy/repo-strategy.js | 4 +++- src/strategy/user-strategy.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/strategy/organization-strategy.js b/src/strategy/organization-strategy.js index 67d1f96..ea5ee25 100644 --- a/src/strategy/organization-strategy.js +++ b/src/strategy/organization-strategy.js @@ -60,7 +60,9 @@ module.exports = class OrganizationStrategy extends Strategy { // Normalize results of each query so that we get a `versions` array for each package in either case. if (this.version) { - return result.organization.packages.nodes.map((it) => ({ ...it, versions: [it.version] })) + return result.organization.packages.nodes + .filter((it) => !!it.version) + .map((it) => ({ ...it, versions: [it.version] })) } else { return result.organization.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes })) } diff --git a/src/strategy/repo-strategy.js b/src/strategy/repo-strategy.js index 2d39b7a..0ef2cc0 100644 --- a/src/strategy/repo-strategy.js +++ b/src/strategy/repo-strategy.js @@ -64,7 +64,9 @@ module.exports = class RepoStrategy extends Strategy { // Normalize results of each query so that we get a `versions` array for each package in either case. if (this.version) { - return result.repository.packages.nodes.map((it) => ({ ...it, versions: [it.version] })) + return result.repository.packages.nodes + .filter((it) => !!it.version) + .map((it) => ({ ...it, versions: [it.version] })) } else { return result.repository.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes })) } diff --git a/src/strategy/user-strategy.js b/src/strategy/user-strategy.js index a3c82dd..a3a4cb5 100644 --- a/src/strategy/user-strategy.js +++ b/src/strategy/user-strategy.js @@ -60,7 +60,7 @@ module.exports = class UserStrategy extends Strategy { // Normalize results of each query so that we get a `versions` array for each package in either case. if (this.version) { - return result.user.packages.nodes.map((it) => ({ ...it, versions: [it.version] })) + return result.user.packages.nodes.filter((it) => !!it.version).map((it) => ({ ...it, versions: [it.version] })) } else { return result.user.packages.nodes.map((it) => ({ ...it, versions: it.versions.nodes })) }