-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain non-variable sub route on breadcrumbs (#5526)
- Loading branch information
1 parent
00d9dc7
commit ce2874a
Showing
2 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const variableRouteRegex = /\[.*]/; | ||
|
||
/** | ||
* Gets sub route with prefix of path if it does not have any variables. | ||
* This helps to easily switch to another org/project but keep the same sub route like settings/alerts | ||
* @param path | ||
* @param route | ||
*/ | ||
export function getNonVariableSubRoute(path: string, route: string) { | ||
const pathParts = path.split("/"); | ||
const routeParts = route.split("/").slice(pathParts.length); | ||
if ( | ||
// if any sub route has a variable then do not return sub route | ||
routeParts.some((p) => p.match(variableRouteRegex)) || | ||
routeParts.length === 0 | ||
) { | ||
return ""; | ||
} | ||
|
||
return "/" + routeParts.join("/"); | ||
} |
ce2874a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ui.rilldata.in as production
🚀 Deployed on https://66cca3f402053225458d1945--rill-ui-dev.netlify.app