From baa2ec822d9f6e801a332bff6d5f1410f0bf0ee7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 24 Aug 2022 15:01:30 +0200 Subject: [PATCH] core-app-api: fix handling of empty paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: blam Co-authored-by: Johan Haals Signed-off-by: Patrik Oldsberg --- packages/core-app-api/src/app/AppManager.test.tsx | 2 +- packages/core-app-api/src/routing/RouteResolver.ts | 4 ++-- packages/core-app-api/src/routing/validation.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core-app-api/src/app/AppManager.test.tsx b/packages/core-app-api/src/app/AppManager.test.tsx index 467145acfc..c70b43581a 100644 --- a/packages/core-app-api/src/app/AppManager.test.tsx +++ b/packages/core-app-api/src/app/AppManager.test.tsx @@ -518,7 +518,7 @@ describe('Integration Test', () => { , ), ).toThrow( - 'Parameter :thing is duplicated in path /test/:thing/some/:thing', + 'Parameter :thing is duplicated in path test/:thing/some/:thing', ); }); expect(errorLogs).toEqual([ diff --git a/packages/core-app-api/src/routing/RouteResolver.ts b/packages/core-app-api/src/routing/RouteResolver.ts index 31ea23d59f..f17c549bc6 100644 --- a/packages/core-app-api/src/routing/RouteResolver.ts +++ b/packages/core-app-api/src/routing/RouteResolver.ts @@ -82,7 +82,7 @@ function resolveTargetRef( // Find the path that our target route is bound to const resolvedPath = routePaths.get(targetRef); - if (!resolvedPath) { + if (resolvedPath === undefined) { return [undefined, '']; } @@ -154,7 +154,7 @@ function resolveBasePath( // what parameters those are. const diffPaths = refDiffList.slice(0, -1).map(ref => { const path = routePaths.get(ref); - if (!path) { + if (path === undefined) { throw new Error(`No path for ${ref}`); } if (path.includes(':')) { diff --git a/packages/core-app-api/src/routing/validation.ts b/packages/core-app-api/src/routing/validation.ts index d8be7ee9bc..63950b9fdc 100644 --- a/packages/core-app-api/src/routing/validation.ts +++ b/packages/core-app-api/src/routing/validation.ts @@ -41,7 +41,7 @@ export function validateRouteParameters( let fullPath = ''; while (currentRouteRef) { const path = routePaths.get(currentRouteRef); - if (!path) { + if (path === undefined) { throw new Error(`No path for ${currentRouteRef}`); } fullPath = joinPaths(path, fullPath);