- Add admin middleware protecting /admin page (ROLE_ADMIN check) - Fix useAvatarService to use useApi() with FormData detection - Create extractIdFromIri() utility, replace manual IRI parsing - Remove redundant Nitro devProxy (Vite proxy handles dev) Tickets: T-014, T-015, T-017, T-021 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 lines
373 B
TypeScript
12 lines
373 B
TypeScript
/**
|
|
* Extract the numeric ID from an API Platform IRI string.
|
|
* Example: "/api/projects/5" → 5
|
|
*/
|
|
export function extractIdFromIri(iri: string | null | undefined): number {
|
|
if (!iri) return 0
|
|
const lastSlash = iri.lastIndexOf('/')
|
|
if (lastSlash === -1) return 0
|
|
const id = Number(iri.substring(lastSlash + 1))
|
|
return Number.isFinite(id) ? id : 0
|
|
}
|