Skip to content

Commit

Permalink
remove filter url parameter if there is no input
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarning committed Feb 12, 2024
1 parent 4aa83a9 commit d862c01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ window.onload = () => {
$('#filter').oninput = function () {
const filter = this.value.toLowerCase()
// Add filter to URL
history.replaceState(null, null, document.location.href.split("?")[0] + "?filter=" + encodeURIComponent(filter));
if (filter) {
history.replaceState(null, null, document.location.href.split("?")[0] + "?filter=" + encodeURIComponent(filter));
} else {
history.replaceState(null, null, document.location.href.split("?")[0]);
}
addImages(myJson, filter);
}

Expand Down

0 comments on commit d862c01

Please sign in to comment.