63ccf03dac
* move getApiUrl to api folder * adjust imports * tanstack-query example with homeData * small adjustments * fix key collision * new MusicSource persistent mechanism example * add error handling & set sveltekit to SPA mode * remove unnecessary ssr test
17 lines
582 B
TypeScript
17 lines
582 B
TypeScript
import { isValidMbid } from '$lib/utils/formatting';
|
|
import { getApiUrl } from '$lib/api/api-utils';
|
|
|
|
export function isAbortError(error: unknown): boolean {
|
|
return (
|
|
(error instanceof DOMException && error.name === 'AbortError') ||
|
|
(error instanceof Error && error.name === 'AbortError')
|
|
);
|
|
}
|
|
|
|
export function getCoverUrl(coverUrl: string | null | undefined, albumId: string): string {
|
|
if (isValidMbid(albumId)) {
|
|
return getApiUrl(`/api/v1/covers/release-group/${albumId}?size=250`);
|
|
}
|
|
return coverUrl || getApiUrl(`/api/v1/covers/release-group/${albumId}?size=250`);
|
|
}
|