Skip to content

Commit

Permalink
fix: prevent error when viewing repo and not logged in (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgchan authored Aug 22, 2023
1 parent 9ab81e6 commit 05fcf5e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/colorPreference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const prefersDarkMode = (cookieString: string): boolean => {
const regex = /(?<=\bcolor_mode=)[^;]+/g;
const match = regex.exec(cookieString);
const cookie = match && JSON.parse(decodeURIComponent(match[0]));
const colorScheme: ColorScheme = cookie.color_mode ?? "auto";
const colorScheme: ColorScheme = cookie?.color_mode ?? "auto";

if (colorScheme === "auto") {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
Expand Down

0 comments on commit 05fcf5e

Please sign in to comment.