From a47d55d1a27a9227c4c24876cd74b7cb9fcded83 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Thu, 1 Feb 2024 19:23:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20trailing=20slashes=20not?= =?UTF-8?q?=20handled=20in=20Settings=20(#19640)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apps/admin-x-framework/src/providers/RoutingProvider.tsx | 3 +-- .../src/components/providers/SettingsRouter.tsx | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/admin-x-framework/src/providers/RoutingProvider.tsx b/apps/admin-x-framework/src/providers/RoutingProvider.tsx index 46f93f2c11..f14c3a8072 100644 --- a/apps/admin-x-framework/src/providers/RoutingProvider.tsx +++ b/apps/admin-x-framework/src/providers/RoutingProvider.tsx @@ -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 || {}; diff --git a/apps/admin-x-settings/src/components/providers/SettingsRouter.tsx b/apps/admin-x-settings/src/components/providers/SettingsRouter.tsx index d5cb055bfd..c2fff273d1 100644 --- a/apps/admin-x-settings/src/components/providers/SettingsRouter.tsx +++ b/apps/admin-x-settings/src/components/providers/SettingsRouter.tsx @@ -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',