fix: improve category URL handling with additional checks (#472)
Some checks failed
Code quality / quality (push) Failing after 4s
Build and Check / Astro Check for Node.js 22 (push) Failing after 4s
Build and Check / Astro Check for Node.js 23 (push) Failing after 5s
Build and Check / Astro Build for Node.js 22 (push) Failing after 5s
Build and Check / Astro Build for Node.js 23 (push) Failing after 5s

* fix: improve category URL handling with additional checks

* Update src/utils/url-utils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Katsuyuki Karasawa
2025-05-30 14:55:55 +09:00
committed by GitHub
parent 87eff4a087
commit 4b30ff2b7b

View File

@@ -1,3 +1,6 @@
import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation";
export function pathsEqual(path1: string, path2: string) {
const normalizedPath1 = path1.replace(/^\/|\/$/g, "").toLowerCase();
const normalizedPath2 = path2.replace(/^\/|\/$/g, "").toLowerCase();
@@ -19,7 +22,12 @@ export function getTagUrl(tag: string): string {
}
export function getCategoryUrl(category: string): string {
if (!category) return url("/archive/");
if (
!category ||
category.trim() === "" ||
category.trim().toLowerCase() === i18n(I18nKey.uncategorized).toLowerCase()
)
return url("/archive/");
return url(`/archive/?category=${encodeURIComponent(category.trim())}`);
}