function addHistory(value) {
  const url = new URL(window.location.href);

  // use this to only modify the param "q" and not overwrite any other existing params
  url.searchParams.set('q', value);

  window.history.pushState({}, '', url);
  search();
}
Helper to consistently add history and reload results