From 780feb7eb84dc9c20b04e910ec8c07d635042ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vest=C3=B8l?= Date: Sun, 10 Jun 2018 09:53:22 +0200 Subject: [PATCH] Prevented \n in playerCount, webinterface function to get queryString params added --- client.js | 2 +- static/main.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client.js b/client.js index 9f6750cc..1777fb77 100644 --- a/client.js +++ b/client.js @@ -618,7 +618,7 @@ function instanceManagement() { publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config mods:modHashes, instanceName: instance, - playerCount, + playerCount:playerCount.replace(/(\r\n\t|\n|\r\t)/gm, ""), } function callback(err, mac) { diff --git a/static/main.js b/static/main.js index 0cdcc55c..5316a6a7 100644 --- a/static/main.js +++ b/static/main.js @@ -81,6 +81,18 @@ function djb2(str){ } return hash; } + +// get queryString parameters +function getParameterByName(name, url) { + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); +} + // callback(err, json) function getJSON(url, callback) { return new Promise((resolve, reject) => {