diff --git a/static/standardUI/js/navbar.js b/static/standardUI/js/navbar.js index 29f92185..0ddfda3f 100644 --- a/static/standardUI/js/navbar.js +++ b/static/standardUI/js/navbar.js @@ -1,10 +1,13 @@ function search() { - var input = document.getElementById("searchInput").value; - if (input === "" || input.replace(/\s/g, "") === "") { + const input = document.querySelector("#searchInput").value; + if (input === "" || input.trim() === "") { } else { - window.location.href = `/search/${input.replace(/\s/g, "+")}`; + window.location.href = `/search/${encodeURIComponent( + escape(input.trim()) + )}`; } } + function hamburger() { document.getElementById("hamburgerDropdown").classList.toggle("show"); } diff --git a/static/standardUI/js/searchBar.js b/static/standardUI/js/searchBar.js index b2e966fc..2cb8bc86 100644 --- a/static/standardUI/js/searchBar.js +++ b/static/standardUI/js/searchBar.js @@ -1,8 +1,9 @@ function searchBar() { - var input = document.querySelector("#searchBarInput").value; - console.log(input); - if (input === "" || input.replace(/\s/g, "") === "") { + const input = document.querySelector("#searchBarInput").value; + if (input === "" || input.trim() === "") { } else { - window.location.href = `/search/${input.replace(/\s/g, "+")}`; + window.location.href = `/search/${encodeURIComponent( + escape(input.trim()) + )}`; } } diff --git a/static/tailwindUI/js/navbar.js b/static/tailwindUI/js/navbar.js index 29f92185..0ddfda3f 100644 --- a/static/tailwindUI/js/navbar.js +++ b/static/tailwindUI/js/navbar.js @@ -1,10 +1,13 @@ function search() { - var input = document.getElementById("searchInput").value; - if (input === "" || input.replace(/\s/g, "") === "") { + const input = document.querySelector("#searchInput").value; + if (input === "" || input.trim() === "") { } else { - window.location.href = `/search/${input.replace(/\s/g, "+")}`; + window.location.href = `/search/${encodeURIComponent( + escape(input.trim()) + )}`; } } + function hamburger() { document.getElementById("hamburgerDropdown").classList.toggle("show"); }