From c77d2b4b3b9308b7b4de3cd39a10c29e94ad2203 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 11 Sep 2020 13:14:55 +0200 Subject: [PATCH] refactor(matcher): better error message --- src/matcher/pathTokenizer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/matcher/pathTokenizer.ts b/src/matcher/pathTokenizer.ts index c1d5d5af..bb54f3a5 100644 --- a/src/matcher/pathTokenizer.ts +++ b/src/matcher/pathTokenizer.ts @@ -47,7 +47,8 @@ export function tokenizePath(path: string): Array { if (!path) return [[]] if (path === '/') return [[ROOT_TOKEN]] // remove the leading slash - if (path[0] !== '/') throw new Error('A non-empty path must start with "/"') + if (!path.startsWith('/')) + throw new Error(`Route "${path}" should be "/${path}".`) // if (tokenCache.has(path)) return tokenCache.get(path)! -- 2.47.2