title: Javascript - "history.pushState" replaces regular "&" with "&amp;". How to avoid it?
body: <p>I am doing an AJAX request in Rails and after executing it, I'd like to modify the URL and put there all there parameters.</p>
  
  <p>So this is how I obtained the relative URL in the Rails controller:</p>
  
  <pre><code>@url_params = request.original_fullpath 
  # =&gt; /members/info/detail?currency=usd&amp;year=2016
  </code></pre>
  
  <p>Then, in the JS file:</p>
  
  <pre><code>console.log("&lt;%= @url_params %&gt;");
  # =&gt; /members/info/detail?currency=usd&amp;amp;year=2016
  </code></pre>
  
  <p>So I tried:</p>
  
  <pre><code>var url = "&lt;%= @url_params %&gt;";
  var replaced_url = url.replace("&amp;amp;", "&amp;");
  # =&gt; /members/info/detail?currency=usd&amp;amp;year=2016
  </code></pre>
  
  <p>but it doesn't work neither.</p>
  
  <p>When I do <code>history.pushState("", "", replaced_url);</code>, in the URL is still the <code>$amp;</code> instead of only <code>&amp;</code>.</p>
  
  <p>How to push the URL without the <code>&amp;amp;</code> characters?</p>
  
  <p>Thank you</p>