SzuruChrome/src/utils.ts

19 lines
611 B
TypeScript

export function getUrl(root: string, ...parts: string[]): string {
let url = root.replace(/\/+$/, "");
for (const part of parts) {
url += "/" + part.replace(/\/+$/, "");
}
return url;
}
export function encodeTagName(tagName: string) {
// Searching for posts with re:zero will show an error message about unknown named token.
// Searching for posts with re\:zero will show posts tagged with re:zero.
return tagName.replace(/:/g, "\\:");
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getErrorMessage(ex: any) {
return ex.description ?? ex.message ?? ex;
}