Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/dashmate/src/ssl/zerossl/Certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Certificate {
created;

/**
* @type {Date}
* @type {Date|null}
*/
expires;

Expand All @@ -35,7 +35,8 @@ export default class Certificate {
* @param {string} object.common_name - The common name of the certificate.
* @param {string} object.additional_domains - Any additional domains in the certificate.
* @param {string} object.created - The exact time the certificate was created.
* @param {string} object.expires - The exact time the certificate will expire.
* @param {string|null} object.expires - The exact time the certificate will expire,
* or null until the certificate is issued.
* @param {string} object.status - The current certificate status.
* @param {string|null} object.validation_type - The selected verification type, or null
* if not initiated.
Expand Down Expand Up @@ -64,7 +65,7 @@ export default class Certificate {
* the CNAME-record for domain verification.
*/
constructor(object) {
const expires = convertDate(object.expires);
const expires = object.expires === null ? null : convertDate(object.expires);
const created = convertDate(object.created);

Object.assign(this, {
Expand Down Expand Up @@ -105,6 +106,10 @@ export default class Certificate {
* @param {number} days
*/
isExpiredInDays(days) {
if (this.expires === null) {
return false;
Comment thread
shumkov marked this conversation as resolved.
}

const expiresInDays = new Date(this.expires);
expiresInDays.setDate(expiresInDays.getDate() - days);

Expand Down
14 changes: 14 additions & 0 deletions packages/dashmate/test/unit/ssl/zerossl/Certificate.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Certificate from '../../../../src/ssl/zerossl/Certificate.js';

describe('Certificate', () => {
it('should handle a pending certificate without an expiration date', () => {
const certificate = new Certificate({
status: 'pending_validation',
created: '2026-08-18 09:04:19',
expires: null,
});

expect(certificate.expires).to.be.null();
expect(certificate.isExpiredInDays(30)).to.be.false();
});
});
Loading