]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor(matcher): parser should throw on invalid path
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 2 Oct 2020 10:07:11 +0000 (12:07 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 2 Oct 2020 10:07:11 +0000 (12:07 +0200)
src/matcher/pathTokenizer.ts

index aa1dd7b385e6fad69a610decfbf7a5ca95a65fe7..6c173de2120a8bfa71d85f561431d1b6fa145294 100644 (file)
@@ -46,10 +46,11 @@ const VALID_PARAM_RE = /[a-zA-Z0-9_]/
 export function tokenizePath(path: string): Array<Token[]> {
   if (!path) return [[]]
   if (path === '/') return [[ROOT_TOKEN]]
-  // remove the leading slash
-  if (__DEV__ && !path.startsWith('/')) {
+  if (!path.startsWith('/')) {
     throw new Error(
-      `Route path should start with a "/": "${path}" should be "/${path}". This will break in production.`
+      __DEV__
+        ? `Route paths should start with a "/": "${path}" should be "/${path}".`
+        : `Invalid path "${path}"`
     )
   }