Skip to content

Commit

Permalink
Update search query function
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmitchell committed Jul 29, 2024
1 parent a38766c commit 05ff120
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions assets/js/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 05ff120

Please sign in to comment.