From ed90e77238fc96d33adc9135b4b4af6223154ae1 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 17 Jan 2023 19:21:55 +0100 Subject: [PATCH] word/quiz: decode uri-encoded location hash Separator # not recognised in correct browsers like chrome. --- word/quiz.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/word/quiz.js b/word/quiz.js index 5283628..dce5f7a 100644 --- a/word/quiz.js +++ b/word/quiz.js @@ -6,6 +6,12 @@ Array.prototype.shuffle = function () { return this; }; +function hashparams() { + // location.hash is not encoded in firefox + const encodedhash = (window.location.href.split('#'))[1] || ''; + return decodeURIComponent(encodedhash).split('#'); +} + class Words { constructor(data, root = undefined) { this.data = data; @@ -111,7 +117,7 @@ class WordQuiz { return selection; } - configure(params = window.location.hash.split('#')) { + configure(params = hashparams()) { const opts = new Map(params.map(arg => arg.split(/[:=](.*)/))); for (let [query, val] of opts) { if (query.match(/^\d+$/)) { -- 2.30.0