From 7a0d8cb52e57de14a0b33aec25c5d8020106a116 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 2 Nov 2021 22:58:31 -0400 Subject: [PATCH] pad: Use URLSearchParams to process search params Also unexport `getUrlVars` because it isn't used outside the file. --- src/static/js/pad.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 1d33a3c99..d2d75f7c7 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -157,27 +157,15 @@ const getParams = () => { // Then URL applied stuff const params = getUrlVars(); - for (const setting of getParameters) { - const value = params[setting.name]; - + const value = params.get(setting.name); if (value && (value === setting.checkVal || setting.checkVal == null)) { setting.callback(value); } } }; -const getUrlVars = () => { - const vars = []; - let hash; - const hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - for (let i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - return vars; -}; +const getUrlVars = () => new URL(window.location.href).searchParams; const sendClientReady = (isReconnect) => { let padId = document.location.pathname.substring(document.location.pathname.lastIndexOf('/') + 1); @@ -744,6 +732,5 @@ exports.baseURL = ''; exports.settings = settings; exports.randomString = randomString; exports.getParams = getParams; -exports.getUrlVars = getUrlVars; exports.pad = pad; exports.init = init;