fix: board crashes with empty string favicon (#2192)
This commit is contained in:
@@ -7,6 +7,7 @@ import "~/styles/gridstack.scss";
|
|||||||
import { IntegrationProvider } from "@homarr/auth/client";
|
import { IntegrationProvider } from "@homarr/auth/client";
|
||||||
import { auth } from "@homarr/auth/next";
|
import { auth } from "@homarr/auth/next";
|
||||||
import { getIntegrationsWithPermissionsAsync } from "@homarr/auth/server";
|
import { getIntegrationsWithPermissionsAsync } from "@homarr/auth/server";
|
||||||
|
import { isNullOrWhitespace } from "@homarr/common";
|
||||||
import { getI18n } from "@homarr/translation/server";
|
import { getI18n } from "@homarr/translation/server";
|
||||||
|
|
||||||
import { createMetaTitle } from "~/metadata";
|
import { createMetaTitle } from "~/metadata";
|
||||||
@@ -48,11 +49,13 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(
|
|||||||
return {
|
return {
|
||||||
title: board.metaTitle ?? createMetaTitle(t("board.content.metaTitle", { boardName: board.name })),
|
title: board.metaTitle ?? createMetaTitle(t("board.content.metaTitle", { boardName: board.name })),
|
||||||
icons: {
|
icons: {
|
||||||
icon: board.faviconImageUrl ?? undefined,
|
icon: !isNullOrWhitespace(board.faviconImageUrl) ? board.faviconImageUrl : undefined,
|
||||||
apple: board.faviconImageUrl ?? undefined,
|
apple: !isNullOrWhitespace(board.faviconImageUrl) ? board.faviconImageUrl : undefined,
|
||||||
},
|
},
|
||||||
appleWebApp: {
|
appleWebApp: {
|
||||||
startupImage: { url: board.faviconImageUrl ?? "/logo/logo.png" },
|
startupImage: {
|
||||||
|
url: !isNullOrWhitespace(board.faviconImageUrl) ? board.faviconImageUrl : "/logo/logo.png",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
export const capitalize = <T extends string>(str: T) => {
|
export const capitalize = <T extends string>(str: T) => {
|
||||||
return (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<T>;
|
return (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isNullOrWhitespace = (value: string | null): value is null => {
|
||||||
|
return value == null || value.trim() === "";
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user