Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { describe, expect, it } from 'vitest';
import { stripChatgptCitations } from './chatgptText.js';
describe('ChatGPT citation cleanup', () => {
it('removes complete single and multi-source tokens without changing surrounding Markdown', () => {
const input = 'A citeturn1search0 and B.citeturn2search3turn2search4\n\n[Source](https://example.com)\n';
const expected = 'A and B.\n\n[Source](https://example.com)\n';
expect(stripChatgptCitations(input)).toBe(expected);
expect(stripChatgptCitations(expected)).toBe(expected);
});
it('removes unterminated reference IDs at line boundaries without consuming the following prose', () => {
expect(stripChatgptCitations('Answer.citeturn1search0turn2view1\n\nKeep this.\nciteturn3search2')).toBe('Answer.\n\nKeep this.\n');
});
it('removes a token cut by the legacy import preview limit', () => {
const footer = '\n\n…(transcript truncated — open the full conversation to see everything)';
expect(stripChatgptCitations(`Answer.citeturn1sea${footer}`)).toBe(`Answer.${footer}`);
});
it('preserves unrelated private-use markup and incomplete tokens rather than eating prose', () => {
const text = 'imageexample citeunfinished\nKeep this. citeturn1search0';
expect(stripChatgptCitations(text)).toBe('imageexample citeunfinished\nKeep this. ');
});
});