From a9a0d61a69845cddacc6d25171ae403b9e0152f2 Mon Sep 17 00:00:00 2001 From: LautaroCesso Date: Mon, 20 Apr 2020 07:32:16 -0300 Subject: [PATCH] Change function to get values of URL. --- client/src/app-components/ticket-list.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client/src/app-components/ticket-list.js b/client/src/app-components/ticket-list.js index 5ffac282..b567b862 100644 --- a/client/src/app-components/ticket-list.js +++ b/client/src/app-components/ticket-list.js @@ -72,7 +72,7 @@ class TicketList extends React.Component { } renderMessage() { - switch (this.getParameterByName('message')) { + switch (this.getQueryVariable('message')) { case 'success': return {i18n('TICKET_SENT')} case 'fail': @@ -121,11 +121,18 @@ class TicketList extends React.Component { return departments; } - getParameterByName(name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + getQueryVariable(variable) { + let query = window.location.search.substring(1); + let vars = query.split("&"); + + for (let i=0; i < vars.length; i++) { + let pair = vars[i].split("="); + if(pair[0] == variable) { + return pair[1]; + } + } + + return false; } getTableHeaders() {