pad: Use URLSearchParams to process search params

Also unexport `getUrlVars` because it isn't used outside the file.
pull/5258/head
Richard Hansen 2021-11-02 22:58:31 -04:00
parent fe87e2df87
commit 7a0d8cb52e
1 changed files with 2 additions and 15 deletions

View File

@ -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;