Skip to content

Commit 04a5d75

Browse files
StefanFriptutrakt-bot[bot]
authored andcommitted
refactor(search): simplify storage host prepend
Drop the host-detection and extension-dedup branches; keep only the leading-slash normalization and use prependHttps for a valid HttpsUrl.
1 parent 48605ab commit 04a5d75

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { prependHttps } from '$lib/utils/url/prependHttps.ts';
2+
13
const STORAGE_HOST = 'media.trakt.tv';
24

35
export function prependStorageHost(
@@ -8,11 +10,6 @@ export function prependStorageHost(
810
return '';
911
}
1012

11-
const hasHost = url.startsWith('http') || url.includes('.trakt.tv');
1213
const path = url.startsWith('/') ? url : `/${url}`;
13-
const imageUrl = hasHost ? url : `${STORAGE_HOST}${path}`;
14-
15-
return imageUrl.endsWith(extension)
16-
? imageUrl as HttpsUrl
17-
: `${imageUrl}${extension}` as HttpsUrl;
14+
return prependHttps(`${STORAGE_HOST}${path}${extension}`);
1815
}

0 commit comments

Comments
 (0)