Merge pull request #2328 from bittoby/fix/project-slug-collision

Fix: project slug collisions for non-English names (#2318)
This commit is contained in:
Dotta 2026-04-01 09:34:23 -05:00 committed by GitHub
commit 6c2c63e0f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { deriveAgentUrlKey, deriveProjectUrlKey } from "@paperclipai/shared";
import { deriveAgentUrlKey, deriveProjectUrlKey, normalizeProjectUrlKey, hasNonAsciiContent } from "@paperclipai/shared";
import type { BillingType, FinanceDirection, FinanceEventKind } from "@paperclipai/shared";
export function cn(...inputs: ClassValue[]) {
@ -156,9 +156,12 @@ export function agentUrl(agent: { id: string; urlKey?: string | null; name?: str
return `/agents/${agentRouteRef(agent)}`;
}
/** Build a project route reference using the short URL key when available. */
/** Build a project route reference, falling back to UUID when the derived key is ambiguous. */
export function projectRouteRef(project: { id: string; urlKey?: string | null; name?: string | null }): string {
return project.urlKey ?? deriveProjectUrlKey(project.name, project.id);
const key = project.urlKey ?? deriveProjectUrlKey(project.name, project.id);
// Guard for rolling deploys or legacy data where the server returned a bare slug without UUID suffix.
if (key === normalizeProjectUrlKey(project.name) && hasNonAsciiContent(project.name)) return project.id;
return key;
}
/** Build a project URL using the short URL key when available. */