refactor(database): 🔥 Simplify media management code

This commit is contained in:
Jesse Wierzbinski 2025-01-28 18:06:33 +01:00
parent cf1104d762
commit bc961b70bb
No known key found for this signature in database
7 changed files with 173 additions and 109 deletions

View file

@ -57,8 +57,11 @@ export const urlToContentFormat = (
};
};
export const mimeLookup = (url: string): Promise<string> => {
const naiveLookup = lookup(url.replace(new URL(url).search, ""));
export const mimeLookup = (url: URL): Promise<string> => {
const urlWithoutSearch = url.toString().replace(url.search, "");
// Strip query params from URL to get the proper file extension
const naiveLookup = lookup(urlWithoutSearch);
if (naiveLookup) {
return Promise.resolve(naiveLookup);