Sfoglia il codice sorgente

Use `history.replaceState` on initial redirect

Eric Zhang 4 anni fa
parent
commit
f19d11f555
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      src/useHash.ts

+ 1 - 1
src/useHash.ts

@@ -9,7 +9,7 @@ function getHash() {
     for (let i = 0; i < idLen; i++) {
     for (let i = 0; i < idLen; i++) {
       id += chars[Math.floor(Math.random() * chars.length)];
       id += chars[Math.floor(Math.random() * chars.length)];
     }
     }
-    window.location.hash = id;
+    window.history.replaceState(null, "", "#" + id);
   }
   }
   return window.location.hash.slice(1);
   return window.location.hash.slice(1);
 }
 }