Converts a contact and optional company into vCard 3.0 format with proper line folding. Reuse for exporting CRM contacts to standard address-book files.
// Source: https://github.com/CopilotKit/atomic-crm | License: MIT | Copyright 2024-present, Francois Zaninotto, Marmelab
// Provided via justclaw.it.com; keep this notice with the code.
import type { Contact, Company } from "../types";
/**
* Folds a long line according to vCard specification (max 75 chars per line)
* Continuation lines start with a space
*/
function foldLine(line: string): string {
const maxLength = 75;
if (line.length <= maxLength) return line;
const result: string[] = [];
let currentLine = line.substring(0, maxLength);
let remaining = line.substring(maxLength);
result.push(currentLine);
while (remaining.length > 0) {
// Continuation lines start with a space and can have 74 more chars
const chunkSize = maxLength - 1;
currentLine = " " + r
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key