mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor: 🚨 Turn every linter rule on and fix issues (there were a LOT :3)
This commit is contained in:
parent
2e98859153
commit
a1e02d0d78
177 changed files with 1826 additions and 1248 deletions
|
|
@ -4,7 +4,9 @@ import { lookup } from "mime-types";
|
|||
export const getBestContentType = (
|
||||
content?: typeof EntityValidator.$ContentFormat,
|
||||
) => {
|
||||
if (!content) return { content: "", format: "text/plain" };
|
||||
if (!content) {
|
||||
return { content: "", format: "text/plain" };
|
||||
}
|
||||
|
||||
const bestFormatsRanked = [
|
||||
"text/x.misskeymarkdown",
|
||||
|
|
@ -14,8 +16,9 @@ export const getBestContentType = (
|
|||
];
|
||||
|
||||
for (const format of bestFormatsRanked) {
|
||||
if (content[format])
|
||||
if (content[format]) {
|
||||
return { content: content[format].content, format };
|
||||
}
|
||||
}
|
||||
|
||||
return { content: "", format: "text/plain" };
|
||||
|
|
@ -24,7 +27,9 @@ export const getBestContentType = (
|
|||
export const urlToContentFormat = (
|
||||
url?: string,
|
||||
): typeof EntityValidator.$ContentFormat | null => {
|
||||
if (!url) return null;
|
||||
if (!url) {
|
||||
return null;
|
||||
}
|
||||
if (url.startsWith("https://api.dicebear.com/")) {
|
||||
return {
|
||||
"image/svg+xml": {
|
||||
|
|
@ -46,7 +51,9 @@ export const urlToContentFormat = (
|
|||
export const mimeLookup = async (url: string) => {
|
||||
const naiveLookup = lookup(url.replace(new URL(url).search, ""));
|
||||
|
||||
if (naiveLookup) return naiveLookup;
|
||||
if (naiveLookup) {
|
||||
return naiveLookup;
|
||||
}
|
||||
|
||||
const fetchLookup = fetch(url, { method: "HEAD" }).then(
|
||||
(response) => response.headers.get("content-type") || "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue