web_reader / src /utils /misc.ts
nomagick's picture
restructure: nolonger a firebase application (#1160)
23a3b80 unverified
raw
history blame
484 Bytes
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}`);
}
}