mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
pad: Use URLSearchParams to process search params
Also unexport `getUrlVars` because it isn't used outside the file.
This commit is contained in:
parent
fe87e2df87
commit
7a0d8cb52e
1 changed files with 2 additions and 15 deletions
|
@ -157,27 +157,15 @@ const getParams = () => {
|
||||||
|
|
||||||
// Then URL applied stuff
|
// Then URL applied stuff
|
||||||
const params = getUrlVars();
|
const params = getUrlVars();
|
||||||
|
|
||||||
for (const setting of getParameters) {
|
for (const setting of getParameters) {
|
||||||
const value = params[setting.name];
|
const value = params.get(setting.name);
|
||||||
|
|
||||||
if (value && (value === setting.checkVal || setting.checkVal == null)) {
|
if (value && (value === setting.checkVal || setting.checkVal == null)) {
|
||||||
setting.callback(value);
|
setting.callback(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUrlVars = () => {
|
const getUrlVars = () => new URL(window.location.href).searchParams;
|
||||||
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 sendClientReady = (isReconnect) => {
|
const sendClientReady = (isReconnect) => {
|
||||||
let padId = document.location.pathname.substring(document.location.pathname.lastIndexOf('/') + 1);
|
let padId = document.location.pathname.substring(document.location.pathname.lastIndexOf('/') + 1);
|
||||||
|
@ -744,6 +732,5 @@ exports.baseURL = '';
|
||||||
exports.settings = settings;
|
exports.settings = settings;
|
||||||
exports.randomString = randomString;
|
exports.randomString = randomString;
|
||||||
exports.getParams = getParams;
|
exports.getParams = getParams;
|
||||||
exports.getUrlVars = getUrlVars;
|
|
||||||
exports.pad = pad;
|
exports.pad = pad;
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue