fix: improve category URL handling with additional checks (#472)

* 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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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())}`);
}