🐛 Fixed trailing slashes not handled in Settings (#19640)

fixes
https://linear.app/tryghost/issue/ENG-609/staff-users-can-no-longer-be-opened-directly-with-their-url

- additionally added an `edit` route for editing staff users, which
fixes a regression.
This commit is contained in:
Ronald Langeveld 2024-02-01 19:23:22 +02:00 committed by GitHub
parent c12e279e0c
commit a47d55d1a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,6 @@ function getHashPath(basePath: string, urlPath: string | undefined) {
}
const regex = new RegExp(`/${basePath}/(.*)`);
const match = urlPath?.match(regex);
if (match) {
const afterSettingsX = match[1];
return afterSettingsX;
@ -84,7 +83,7 @@ const handleNavigation = (basePath: string, currentRoute: string | undefined, lo
};
const matchRoute = (pathname: string, routeDefinition: string) => {
const regex = new RegExp('^' + routeDefinition.replace(/:(\w+)/, '(?<$1>[^/]+)') + '$');
const regex = new RegExp('^' + routeDefinition.replace(/:(\w+)/g, '(?<$1>[^/]+)') + '/?$');
const match = pathname.match(regex);
if (match) {
return match.groups || {};

View File

@ -11,6 +11,7 @@ export const modalPaths: {[key: string]: ModalName} = {
'navigation/edit': 'NavigationModal',
'staff/invite': 'InviteUserModal',
'staff/:slug': 'UserDetailModal',
'staff/:slug/edit': 'UserDetailModal',
'portal/edit': 'PortalModal',
'tiers/add': 'TierDetailModal',
'tiers/:id': 'TierDetailModal',