title: Trying to redirect to the same page but with querystring value
body: <p>I want to redirect to the same page, but add some querystring values.</p>
  
  <p>If there is already a querystring value, I want to strip it out and add a new one.</p>
  
  <p>My code isn't working currently, not sure why:</p>
  
  <pre><code>var url = window.location.href;
  if(url.indexOf("?") &gt; 0) {
    url = url.substring(0, url.indexOf("?"));
  } else {
      url += "?joined=true";
  }
  window.location.replace(url);
  </code></pre>