Plugins: Case-sensitive routes for standalone pages (#62779)

* feat: extend the RouteDescription witha `sensitive` property

* feat: use case-sensitive routes for custom plugin standalone pages

* fix: hcheck for `/a/` instead of `/a`
This commit is contained in:
Levente Balogh 2023-02-03 09:01:34 +01:00 committed by GitHub
parent cf650c9349
commit 48e0ab2142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -58,6 +58,7 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
return (
<Route
exact={route.exact === undefined ? true : route.exact}
sensitive={route.sensitive === undefined ? false : route.sensitive}
path={route.path}
key={route.path}
render={(props) => {

View File

@ -19,4 +19,5 @@ export interface RouteDescriptor {
routeName?: string;
chromeless?: boolean;
exact?: boolean;
sensitive?: boolean;
}

View File

@ -18,10 +18,12 @@ export function getAppPluginRoutes(): RouteDescriptor[] {
const pluginNavSection = getRootSectionForNode(navItem);
const appPluginUrl = `/a/${navItem.pluginId}`;
const path = isStandalonePluginPage(navItem.id) ? navItem.url || appPluginUrl : appPluginUrl; // Only standalone pages can use core URLs, otherwise we fall back to "/a/:pluginId"
const isSensitive = isStandalonePluginPage(navItem.id) && !navItem.url?.startsWith('/a/'); // Have case-sensitive URLs only for standalone pages that have custom URLs
return {
path,
exact: false, // route everything under this path to the plugin, so it can define more routes under this path
sensitive: isSensitive,
component: () => <AppRootPage pluginId={navItem.pluginId} pluginNavSection={pluginNavSection} />,
};
});