diff --git a/assets/js/modules/search.js b/assets/js/modules/search.js index 5b329e2..b7c4e91 100644 --- a/assets/js/modules/search.js +++ b/assets/js/modules/search.js @@ -34,21 +34,14 @@ function ready() { function getQuery(variable) { - var query = window.location.search.substring(1); - var vars = query.split('&'); - - for(var i = 0; i < vars.length; i++) { - - var pair = vars[i].split('='); - - if(pair[0] === variable) { - - return decodeURIComponent(pair[1].replace(/\+/g, '%20')); - - } + var params = new URLSearchParams(window.location.search.substring(1)); + if(params.has(variable)) { + return decodeURIComponent(params.get(variable).replace(/\+/g, '%20')); } + return null; + } var searchTerm = getQuery('q');