openvibers/openvibe.domains Commits

Exclude zero/missing TLD prices from cheapest ordering and badges (#45)

OP OpenVibers committed 12 days ago · 119d0a3415 · 1 file, +7 −3

Changes

ddiff --git a/server/pricing.js b/server/pricing.js
iindex 7da566e..d748902 100644
---- a/server/pricing.js
++++ b/server/pricing.js
@@@ -28,9 +28,13 @@ const cents = (n) => Math.round((n + 1e-9) * 100) / 100;
function priceRows(rows) {
const list = (Array.isArray(rows) ? rows : []).map((row, index) => {
const r = row && typeof row === 'object' ? row : {};
-- const register = num(r.register);
-- const renew = num(r.renew);
-- const fiveYear = num(r.five_year);
++ // A price of 0 means the registrar does not sell that ending: treat it as missing.
++ const registerRaw = num(r.register);
++ const renewRaw = num(r.renew);
++ const fiveYearRaw = num(r.five_year);
++ const register = registerRaw === 0 ? null : registerRaw;
++ const renew = renewRaw === 0 ? null : renewRaw;
++ const fiveYear = fiveYearRaw === 0 ? null : fiveYearRaw;
const y1 = register == null ? null : cents(register);
const y3 = register == null || renew == null ? null : cents(register + 2 * renew);
const y5 = fiveYear != null ? cents(fiveYear)