From 1e22574000d8893e66066ac689d8d8d8c444547d Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 18 May 2026 15:04:27 +1000 Subject: [PATCH] Fix nulls showing in certificate rows --- backend/models/certificate.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/models/certificate.js b/backend/models/certificate.js index ad6e0a65f..857c067e4 100644 --- a/backend/models/certificate.js +++ b/backend/models/certificate.js @@ -15,6 +15,16 @@ Model.knex(db()); const boolFields = ["is_deleted"]; +const cleanDomainNames = (domainNames) => { + // Sort domain_names + if (typeof domainNames !== "undefined") { + const newDomainNames = domainNames.filter((name) => name !== null); + newDomainNames.sort(); + return newDomainNames; + } + return []; +}; + class Certificate extends Model { $beforeInsert() { this.created_on = now(); @@ -26,25 +36,17 @@ class Certificate extends Model { } // Default for domain_names - if (typeof this.domain_names === "undefined") { - this.domain_names = []; - } + this.domain_names = cleanDomainNames(this.domain_names); // Default for meta if (typeof this.meta === "undefined") { this.meta = {}; } - - this.domain_names.sort(); } $beforeUpdate() { this.modified_on = now(); - - // Sort domain_names - if (typeof this.domain_names !== "undefined") { - this.domain_names.sort(); - } + this.domain_names = cleanDomainNames(this.domain_names); } $parseDatabaseJson(json) {