Files
Netcatty/lib/utils.ts
T
bincxz a21970a278 Refactors terminal paste line ending normalization
Extracts the logic for normalizing line endings (CRLF to LF) during clipboard paste operations into a shared utility function.

This improves code reusability and consistency across different paste mechanisms, ensuring that pasted content always uses Unix-style line endings and prevents issues like extra blank lines in the terminal.
2026-01-20 13:56:05 +08:00

15 lines
483 B
TypeScript
Executable File

import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
/**
* Normalize line endings to LF (Unix style).
* Converts CRLF (Windows) and standalone CR (old Mac) to LF.
* Used for clipboard paste operations in terminal to avoid extra blank lines.
*/
export function normalizeLineEndings(text: string): string {
return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
}