aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 13:36:32 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-22 14:37:10 -0500
commit7afc23427e61d7a36a1a700c45a42f7ee5fde0c8 (patch)
tree292ba0551ba8eccdc501ed44aca7095a5783e9e6 /ext/mixed/js/audio.js
parent163211ade323f09ad9de7861e1eeab8d344bacb8 (diff)
Use URLSearchParams
Diffstat (limited to 'ext/mixed/js/audio.js')
-rw-r--r--ext/mixed/js/audio.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js
index 47db5c75..fe5982dd 100644
--- a/ext/mixed/js/audio.js
+++ b/ext/mixed/js/audio.js
@@ -72,19 +72,15 @@ class TextToSpeechAudio {
const m = /^tts:[^#?]*\?([^#]*)/.exec(ttsUri);
if (m === null) { return null; }
- const searchParameters = {};
- for (const group of m[1].split('&')) {
- const sep = group.indexOf('=');
- if (sep < 0) { continue; }
- searchParameters[decodeURIComponent(group.substring(0, sep))] = decodeURIComponent(group.substring(sep + 1));
- }
-
- if (!searchParameters.text) { return null; }
+ const searchParameters = new URLSearchParams(m[1]);
+ const text = searchParameters.get('text');
+ let voice = searchParameters.get('voice');
+ if (text === null || voice === null) { return null; }
- const voice = audioGetTextToSpeechVoice(searchParameters.voice);
+ voice = audioGetTextToSpeechVoice(voice);
if (voice === null) { return null; }
- return new TextToSpeechAudio(searchParameters.text, voice);
+ return new TextToSpeechAudio(text, voice);
}
}