]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(warn): warn invalid hash
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 3 May 2020 21:33:03 +0000 (23:33 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 3 May 2020 21:38:34 +0000 (23:38 +0200)
src/router.ts

index e02bf3e2926b638ff94b5b5da9242ce948428f7d..cb8da2ece6f8669bb60d514ec054adff2cf0c476 100644 (file)
@@ -284,6 +284,12 @@ export function createRouter(options: RouterOptions): Router {
 
     const hash = encodeHash(rawLocation.hash || '')
 
+    if (__DEV__ && hash && hash[0] !== '#') {
+      warn(
+        `A \`hash\` should always start with the character "#". Replace "${hash}" with "#${hash}".`
+      )
+    }
+
     // put back the unencoded params as given by the user (avoid the cost of decoding them)
     matchedRoute.params =
       'params' in rawLocation