word/quiz: apply subsequent hash parameters
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 19 Dec 2023 19:40:15 +0000 (20:40 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 28 Dec 2023 07:19:58 +0000 (08:19 +0100)
Broken (or unfinished) in commit v1.13-53-ged90e77238 (2023-02-09)
[decode uri-encoded location hash].

word/quiz.js

index dce5f7a43ace9c973c726432f70d651112cbea69..5498809f67ceb2bbb0ce9a7d31ab8205217b6277 100644 (file)
@@ -7,9 +7,12 @@ Array.prototype.shuffle = function () {
 };
 
 function hashparams() {
-       // location.hash is not encoded in firefox
-       const encodedhash = (window.location.href.split('#'))[1] || '';
-       return decodeURIComponent(encodedhash).split('#');
+       const encodedhash = window.location.href.split('#').slice(1) || '';
+       if (encodedhash.length == 1) {
+               // location.hash is not encoded in firefox
+               return decodeURIComponent(encodedhash).split('#');
+       }
+       return encodedhash;
 }
 
 class Words {