fix(nexus): tighten settings-route guard in ModeBreadcrumb (phase 8)
Code-quality review for Task 2 caught a startsWith false-positive: `/instance/settings-foo` was matching the settings branch of deriveBreadcrumbSegments and producing nonsense output like ["SETTINGS", "-FOO"]. Tightened the guard to require an exact match or a literal trailing slash before entering the settings branch. Added three test cases to lock it in: - /instance/settings (exact, no trailing) -> ["SETTINGS"] - /instance/settings-foo -> ["HOME"] - /instance/settings-foo/bar -> ["HOME"] 22 tests pass. No behavior change for any previously-tested path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bd4e7c5c5d
commit
1de78f855f
2 changed files with 4 additions and 1 deletions
|
|
@ -38,6 +38,9 @@ describe("deriveBreadcrumbSegments", () => {
|
|||
["/NEX/routines", ["PROJECTS"]],
|
||||
["/instance/settings/general", ["SETTINGS"]],
|
||||
["/instance/settings/integrations", ["SETTINGS", "INTEGRATIONS"]],
|
||||
["/instance/settings", ["SETTINGS"]],
|
||||
["/instance/settings-foo", ["HOME"]],
|
||||
["/instance/settings-foo/bar", ["HOME"]],
|
||||
["/", ["HOME"]],
|
||||
["/unknown/path", ["HOME"]],
|
||||
])("maps %s to %o", (input, expected) => {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { cn } from "@/lib/utils";
|
|||
*/
|
||||
export function deriveBreadcrumbSegments(pathname: string): string[] {
|
||||
// /instance/settings/...
|
||||
if (pathname.startsWith("/instance/settings")) {
|
||||
if (pathname === "/instance/settings" || pathname.startsWith("/instance/settings/")) {
|
||||
const rest = pathname.replace(/^\/instance\/settings\/?/, "");
|
||||
if (!rest) return ["SETTINGS"];
|
||||
const leaf = rest.split("/")[0] ?? "";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue