Skip to content

Commit 3f448d2

Browse files
author
martgil
committed
refactor: use .toISOString() in compatibility.ts
1 parent 6b747be commit 3f448d2

File tree

1 file changed

+5
-3
lines changed
  • extension/js/common/core/crypto

1 file changed

+5
-3
lines changed

extension/js/common/core/crypto/key.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ export class KeyUtil {
275275
const opgpresult = await OpenPGPKey.diagnose(key, passphrase);
276276
result = new Map<string, string>([...result, ...opgpresult]);
277277
}
278-
result.set(`expiration`, KeyUtil.formatResult(key.expiration));
278+
const expirationIso = key.expiration ? new Date(key.expiration).toISOString() : undefined;
279+
result.set(`expiration`, KeyUtil.formatResult(expirationIso));
279280
result.set(`internal dateBeforeExpiration`, await KeyUtil.formatResultAsync(async () => KeyUtil.dateBeforeExpirationIfAlreadyExpired(key)));
280281
result.set(`internal usableForEncryption`, KeyUtil.formatResult(key.usableForEncryption));
281282
result.set(`internal usableForSigning`, KeyUtil.formatResult(key.usableForSigning));
@@ -292,8 +293,9 @@ export class KeyUtil {
292293
}
293294
}
294295

295-
public static formatResult(value: unknown): string {
296-
return `[-] ${String(value)}`;
296+
public static formatResult(value: unknown | undefined): string {
297+
const formattedOutput = value !== undefined ? (value as string) : '-';
298+
return `[-] ${formattedOutput}`;
297299
}
298300

299301
public static async asPublicKey(key: Key): Promise<Key> {

0 commit comments

Comments
 (0)