From 7ebb1ca5be08785dee511e0d10ff818b3466bda4 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 24 Jun 2022 01:26:15 +0900 Subject: [PATCH] fix(nirax): Normalize path (#8877) --- packages/client/src/nirax.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/client/src/nirax.ts b/packages/client/src/nirax.ts index d21978744..cae4edaf1 100644 --- a/packages/client/src/nirax.ts +++ b/packages/client/src/nirax.ts @@ -35,7 +35,7 @@ function parsePath(path: string): ParsedPath { wildcard, optional, }); - } else { + } else if (part.length !== 0) { res.push(part); } } @@ -85,9 +85,11 @@ export class Router extends EventEmitter<{ if (_DEV_) console.log('Routing: ', path, queryString); + const _parts = path.split('/').filter(part => part.length !== 0); + forEachRouteLoop: for (const route of this.routes) { - let parts = path.split('/'); + let parts = [ ..._parts ]; const props = new Map(); pathMatchLoop: