Skip to content

Commit a592350

Browse files
committed
fix: simplify short api key preview
1 parent 6808b72 commit a592350

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/utils/prompt.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export async function promptText(options: {
4747
const API_KEY_VISIBLE_LENGTH = 30;
4848

4949
export function apiKeyPreview(value: string): string {
50+
if (value.length <= API_KEY_VISIBLE_LENGTH) return value;
5051
const visible = value.slice(0, API_KEY_VISIBLE_LENGTH);
51-
const ellipsis = value.length > API_KEY_VISIBLE_LENGTH ? '....' : '';
52-
return `${visible}${ellipsis} (${value.length} chars)`;
52+
return `${visible}.... (${value.length} chars)`;
5353
}
5454

5555
export async function promptApiKey(options: { message: string }): Promise<string | undefined> {

‎test/utils/prompt.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { describe, expect, it } from 'bun:test';
33
import { apiKeyPreview } from '../../src/utils/prompt';
44

55
describe('apiKeyPreview', () => {
6-
it('shows at most 30 key characters followed by the total length', () => {
7-
expect(apiKeyPreview('abc')).toBe('abc (3 chars)');
8-
expect(apiKeyPreview('a'.repeat(30))).toBe(`${'a'.repeat(30)} (30 chars)`);
6+
it('shows the total length only when the key is truncated', () => {
7+
expect(apiKeyPreview('abc')).toBe('abc');
8+
expect(apiKeyPreview('a'.repeat(30))).toBe('a'.repeat(30));
99
expect(apiKeyPreview('a'.repeat(125))).toBe(`${'a'.repeat(30)}.... (125 chars)`);
1010
});
1111
});

0 commit comments

Comments
 (0)