Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add the missing component check if there are 3 elements in the path

天舟75aa8b93e845
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index fca2ed1b80..98e5b59c5d 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -11,61 +11,71 @@ const getters = {
routeSlug: (state: RouterState) => (
currentRoute: RouteLocationNormalized
): RouterSlug => {
- // /task/:taskSlug
- // Total 2 elements, 2nd element is the task slug
- const taskComponents = currentRoute.path.match(
- "/task/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
- if (taskComponents[1]) {
- return {
- taskSlug: taskComponents[1],
- };
+ {
+ // /task/:taskSlug
+ // Total 2 elements, 2nd element is the task slug
+ const taskComponents = currentRoute.path.match(
+ "/task/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined];
+ if (taskComponents[1]) {
+ return {
+ taskSlug: taskComponents[1],
+ };
+ }
}
- // /instance/:instanceSlug/db/:databaseSlug
- // Total 3 elements, 2nd element is the instance slug, 3rd element is the data source slug
- const databaseComponents = currentRoute.path.match(
- "/instance/([0-9a-zA-Z_-]+)/db/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
- if (databaseComponents[1]) {
- return {
- instanceSlug: databaseComponents[1],
- databaseSlug: databaseComponents[2],
- };
+ {
+ // /instance/:instanceSlug/db/:databaseSlug
+ // Total 3 elements, 2nd element is the instance slug, 3rd element is the data source slug
+ const databaseComponents = currentRoute.path.match(
+ "/instance/([0-9a-zA-Z_-]+)/db/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined, undefined];
+ if (databaseComponents[1] && databaseComponents[2]) {
+ return {
+ instanceSlug: databaseComponents[1],
+ databaseSlug: databaseComponents[2],
+ };
+ }
}
- // /instance/:instanceSlug/ds/:dataSourceSlug
- // Total 3 elements, 2nd element is the instance slug, 3rd element is the data source slug
- const dataSourceComponents = currentRoute.path.match(
- "/instance/([0-9a-zA-Z_-]+)/ds/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
- if (dataSourceComponents[1]) {
- return {
- instanceSlug: dataSourceComponents[1],
- dataSourceSlug: dataSourceComponents[2],
- };
+ {
+ // /instance/:instanceSlug/ds/:dataSourceSlug
+ // Total 3 elements, 2nd element is the instance slug, 3rd element is the data source slug
+ const dataSourceComponents = currentRoute.path.match(
+ "/instance/([0-9a-zA-Z_-]+)/ds/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined, undefined];
+ if (dataSourceComponents[1] && dataSourceComponents[2]) {
+ return {
+ instanceSlug: dataSourceComponents[1],
+ dataSourceSlug: dataSourceComponents[2],
+ };
+ }
}
- // /instance/:instanceSlug
- // Total 2 elements, 2nd element is the instance slug
- const instanceComponents = currentRoute.path.match(
- "/instance/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
- if (instanceComponents[1]) {
- return {
- instanceSlug: instanceComponents[1],
- };
+ {
+ // /instance/:instanceSlug
+ // Total 2 elements, 2nd element is the instance slug
+ const instanceComponents = currentRoute.path.match(
+ "/instance/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined];
+ if (instanceComponents[1]) {
+ return {
+ instanceSlug: instanceComponents[1],
+ };
+ }
}
- // /u/:principalId
- // Total 2 elements, 2nd element is the principal id
- const profileComponents = currentRoute.path.match(
- "/u/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
- if (profileComponents[1]) {
- return {
- principalId: profileComponents[1],
- };
+ {
+ // /u/:principalId
+ // Total 2 elements, 2nd element is the principal id
+ const profileComponents = currentRoute.path.match(
+ "/u/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined];
+ if (profileComponents[1]) {
+ return {
+ principalId: profileComponents[1],
+ };
+ }
}
return {};