This commit refactors existing text utility functions into the application layer for broad reuse and integrates them across the codebase. Initially, these utilities were confined to test code, which limited their application. Changes: - Move text utilities to the application layer. - Centralize text utilities into dedicated files for better maintainability. - Improve robustness of utility functions with added type checks. - Replace duplicated logic with centralized utility functions throughout the codebase. - Expand unit tests to cover refactored code parts.
20 lines
462 B
TypeScript
20 lines
462 B
TypeScript
import { indentText } from '@/application/Common/Text/IndentText';
|
|
|
|
export interface UrlStatus {
|
|
readonly url: string;
|
|
readonly error?: string;
|
|
readonly code?: number;
|
|
}
|
|
|
|
export function formatUrlStatus(status: UrlStatus): string {
|
|
return [
|
|
`URL: ${status.url}`,
|
|
...status.code !== undefined ? [
|
|
`Response code: ${status.code}`,
|
|
] : [],
|
|
...status.error ? [
|
|
`Error:\n${indentText(status.error)}`,
|
|
] : [],
|
|
].join('\n');
|
|
}
|