title: having trouble overwriting querystring with history.PushState
body: <p>I can't figure out how to correctly use push state. I'm getting weird url's like so:</p>
  
  <p><code>http://website.net/home?http://website.net/home=undefined&amp;tab=browse</code></p>
  
  <p>And can't seem to get it to work no matter what I try. I need domain/path to stay the same, I just want to rebuild the querystring (which I do in another function) then apply <code>history.pushState()</code></p>
  
  <p>Here's a basic look at the code, abbreviated to show the problem in question.</p>
  
  <pre><code>var sk = {
      //push function
      pushState: function(qs,callback){
          var i = 0, uri = '';
          $.each(qs,function(k,v){
              if(k=="" || v==""){
                  delete qs[k];
              }
          });
          $.each(qs,function(k,v){
              if(i == 0){
                  uri +='?';
              }else{
                  uri +='&amp;';
              }
              uri +=k+'='+encodeURIComponent(v);
              i++;
          });
          var obj ={ Title: $('title').html(), Url: uri }
          if(typeof callback !== "undefined" &amp;&amp; callback !== false){
              obj[callback[0]] = callback[1];
          }
          history.pushState(obj,obj.Title,obj.Url);
      },
  
      //parse current url and return querystring
      getQSvars : function(){
          var vars = {}, hash;
          var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
          for(var i = 0; i &lt; hashes.length; i++)
          {
              hash = hashes[i].split('=');
              vars[hash[0]] = hash[1];
          }
          return vars;
      },
  };
  </code></pre>