Replace URIjs with native URLSearchParams

This commit is contained in:
Pavel Djundik 2018-05-28 10:16:00 +03:00
parent 0de90daa64
commit 929047b6a5

View File

@ -1,7 +1,6 @@
"use strict"; "use strict";
const $ = require("jquery"); const $ = require("jquery");
const URI = require("urijs");
const socket = require("../socket"); const socket = require("../socket");
const templates = require("../../views"); const templates = require("../../views");
const options = require("../options"); const options = require("../options");
@ -86,10 +85,10 @@ socket.on("configuration", function(data) {
}); });
}); });
if ($(document.body).hasClass("public")) { if ($(document.body).hasClass("public") && "URLSearchParams" in window) {
const params = URI(document.location.search).search(true); const params = new URLSearchParams(document.location.search);
for (let key in params) { for (let [key, value] of params) {
// Support `channels` as a compatibility alias with other clients // Support `channels` as a compatibility alias with other clients
if (key === "channels") { if (key === "channels") {
key = "join"; key = "join";
@ -99,8 +98,6 @@ socket.on("configuration", function(data) {
continue; continue;
} }
let value = params[key];
if (key === "join") { if (key === "join") {
value = value.split(",").map((chan) => { value = value.split(",").map((chan) => {
if (!chan.match(/^[#&!+]/)) { if (!chan.match(/^[#&!+]/)) {