]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor(matcher): better error message
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 11 Sep 2020 11:14:55 +0000 (13:14 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 11 Sep 2020 11:14:55 +0000 (13:14 +0200)
src/matcher/pathTokenizer.ts

index c1d5d5af12b79291e3ee97aea984ad6fdba4cd2b..bb54f3a5d3f21012ff4df57126086da10970a6a6 100644 (file)
@@ -47,7 +47,8 @@ export function tokenizePath(path: string): Array<Token[]> {
   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)!