mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-23 10:36:09 +00:00
🧹 chore: Spell CSV_BOM as and drop a gratuitous optional chain
`revokeCapability` is typed `Promise<{ deletedCount: number }>` so the
`?.` on `revokeResult?.deletedCount` only obscured that the value cannot
be nullish.
`CSV_BOM` was a literal U+FEFF character invisible in most editors. Now
spelled as the Unicode escape so readers can see the constant; the test
that asserts on the first emitted chunk uses the same escape.
This commit is contained in:
parent
e65dff3bb3
commit
945c77cf6f
3 changed files with 6 additions and 3 deletions
|
|
@ -423,7 +423,7 @@ describe('createAdminAuditLogHandlers', () => {
|
|||
|
||||
await handlers.exportAuditLogCsv(ctx.req, ctx.res);
|
||||
|
||||
expect(ctx.chunks[0]).toBe('');
|
||||
expect(ctx.chunks[0]).toBe('\uFEFF');
|
||||
expect(ctx.chunks).toContain('\r\n');
|
||||
expect(ctx.endCalled()).toBe(true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ import type { Response } from 'express';
|
|||
import type { ServerRequest } from '~/types/http';
|
||||
|
||||
const FORMULA_PREFIX = /^[=+\-@\t\r]/;
|
||||
const CSV_BOM = '';
|
||||
/** UTF-8 BOM, written first so Excel recognizes the encoding on import. Spelled
|
||||
* as a Unicode escape so readers can see the constant in editors that hide
|
||||
* the zero-width glyph. */
|
||||
const CSV_BOM = '\uFEFF';
|
||||
|
||||
const VALID_ACTIONS = new Set<AuditAction>(AUDIT_ACTIONS);
|
||||
const VALID_PRINCIPAL_TYPES = new Set<string>(Object.values(PrincipalType));
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ export function createAdminGrantsHandlers(deps: AdminGrantsDeps): {
|
|||
// Only emit the audit entry when a grant document was actually deleted —
|
||||
// a no-op revoke (the grant never existed) must not appear in the audit
|
||||
// trail or the forensic record becomes misleading.
|
||||
if (revokeResult?.deletedCount > 0) {
|
||||
if (revokeResult.deletedCount > 0) {
|
||||
await emitAudit({
|
||||
action: 'grant_removed',
|
||||
caller,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue