diff --git a/frontend/src/components/routing/BreadcrumbsBox.tsx b/frontend/src/components/routing/BreadcrumbsBox.tsx index deb830d..6e83c2a 100644 --- a/frontend/src/components/routing/BreadcrumbsBox.tsx +++ b/frontend/src/components/routing/BreadcrumbsBox.tsx @@ -1,4 +1,5 @@ -import {faBook, faProjectDiagram, faServer, faUniversity, faUser, faUsers} from "@fortawesome/free-solid-svg-icons" +import {faBook, faExclamationCircle, faProjectDiagram, faServer, faUniversity, faUser, faUsers} from "@fortawesome/free-solid-svg-icons" +import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" import {Box} from "@steffo/bluelib-react" import * as React from "react" import {useSophonPath} from "../../hooks/useSophonPath" @@ -11,7 +12,7 @@ export function BreadcrumbsBox(): JSX.Element { const location = useSophonPath() return ( - + ) : null} + {location.valid ? null : <> + +  Invalid path! + } ) } diff --git a/frontend/src/utils/ParsePath.ts b/frontend/src/utils/ParsePath.ts index 4928484..ace1476 100644 --- a/frontend/src/utils/ParsePath.ts +++ b/frontend/src/utils/ParsePath.ts @@ -58,17 +58,12 @@ interface ParsePathSegmentConfig { function parsePathSegment({path, parsed, regex, key, next}: ParsePathSegmentConfig): ParsedPath { - // If the path is empty, return - if(!path) { - return parsed - } - // Try matching the regex const match = path.match(regex) - // If the match fails, it means the path is invalid + // If the match fails, it means the matching is over if(!match || !match.groups) { - parsed.valid = Boolean(path) + parsed.valid = path === "/" return parsed } @@ -95,7 +90,7 @@ function parsePathSegment({path, parsed, regex, key, next}: ParsePathSegmentConf * @param path - The path to split. */ export function parsePath(path: string): ParsedPath { - return parsePathSegment({ + const result = parsePathSegment({ path, parsed: {count: 0, valid: true}, regex: INSTANCE_REGEX, @@ -142,4 +137,8 @@ export function parsePath(path: string): ParsedPath { }, ] }) + + console.debug("[ParsePath] Parsed", result) + + return result }