Refactor and enhance OCR and API functionalities
- Removed obsolete unit tests for TTS/ASR module. - Deleted unused sample video file. - Introduced OCRImageWrapper component for better OCR image handling with loading, success, and failure states. - Updated copilot plugin to improve transaction handling and added new types for better type safety. - Enhanced web search block plugin to support streaming content updates. - Refactored API utility functions for better error handling and consistency across requests. - Added new configuration for OCR API endpoint. - Consolidated SSE event parsing into a shared utility. - Created string utility functions to reduce code duplication. - Removed outdated test documents related to compression functionality.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Shared string utility functions.
|
||||
* Extracted from repeated patterns across api.js, docBlock.js, proAccept.js, proBlock.js, webSearch.js.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Normalize line endings to Unix-style (\n).
|
||||
* Handles \r\n (Windows), \r (old Mac), and \n (Unix).
|
||||
*/
|
||||
export function normalizeNewlines(value: string = ''): string {
|
||||
return String(value || '').replace(/\r\n?/g, '\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely coerce any value to a non-null string.
|
||||
* Replaces the common `String(x || '')` pattern scattered across 20+ locations.
|
||||
*/
|
||||
export function safeString(value: unknown): string {
|
||||
return String(value ?? '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove trailing slashes from a URL/path string.
|
||||
*/
|
||||
export function stripTrailingSlashes(value: string = ''): string {
|
||||
return safeString(value).replace(/\/+$/, '')
|
||||
}
|
||||
Reference in New Issue
Block a user