mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-01 00:22:00 +08:00
27 lines
621 B
TypeScript
27 lines
621 B
TypeScript
import { ParamValidationError } from 'civkit';
|
|
|
|
export function cleanAttribute(attribute: string | null) {
|
|
return attribute ? attribute.replace(/(\n+\s*)+/g, '\n') : '';
|
|
}
|
|
|
|
|
|
export function tryDecodeURIComponent(input: string) {
|
|
try {
|
|
return decodeURIComponent(input);
|
|
} catch (err) {
|
|
if (URL.canParse(input, 'http://localhost:3000')) {
|
|
return input;
|
|
}
|
|
|
|
throw new ParamValidationError(`Invalid URIComponent: ${input}`);
|
|
}
|
|
}
|
|
|
|
|
|
export async function* toAsyncGenerator<T>(val: T) {
|
|
yield val;
|
|
}
|
|
|
|
export async function* toGenerator<T>(val: T) {
|
|
yield val;
|
|
} |