mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor(api): ♻️ Use URL literal instead of strings
This commit is contained in:
parent
99fac323c8
commit
76d1ccc859
50 changed files with 343 additions and 256 deletions
|
|
@ -30,28 +30,25 @@ export const getBestContentType = (
|
|||
};
|
||||
|
||||
export const urlToContentFormat = (
|
||||
url: string,
|
||||
url: URL,
|
||||
contentType?: string,
|
||||
): ContentFormat | null => {
|
||||
if (!url) {
|
||||
return null;
|
||||
}
|
||||
if (url.startsWith("https://api.dicebear.com/")) {
|
||||
if (url.href.startsWith("https://api.dicebear.com/")) {
|
||||
return {
|
||||
"image/svg+xml": {
|
||||
content: url,
|
||||
content: url.toString(),
|
||||
remote: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
const mimeType =
|
||||
contentType ||
|
||||
lookup(url.replace(new URL(url).search, "")) ||
|
||||
lookup(url.toString().replace(url.search, "")) ||
|
||||
"application/octet-stream";
|
||||
|
||||
return {
|
||||
[mimeType]: {
|
||||
content: url,
|
||||
content: url.toString(),
|
||||
remote: true,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue