code: function() {
      var current = $state.current();
  
      if(current && current.url) {
        var path;
        path = current.url;
  
        // Add parameters or use default parameters
        var params = current.params || {};
        var query = {};
        for(var name in params) {
          var re = new RegExp(':'+name, 'g');
          if(path.match(re)) {
            path = path.replace(re, params[name]);
          } else {
            query[name] = params[name];
          }
        }
  
        $location.path(path);
        $location.search(query);
        
        _url = $location.url();
      }
    }
docs: Update URL based on state