- 
                Notifications
    
You must be signed in to change notification settings  - Fork 688
 
Open
Labels
Description
Hi!
I have to change history state during the change of a slide of a slider in my webpage.
I use history.js:
History.pushState({slide:1}, "Slide 1", "/slide/1");I also have a route registered with page.js:
page(['/slide', '/slide/:num'], function(ctx, next){ //things  });When i use back and forward browser button, i got this error:
Uncaught TypeError: Cannot read property '0' of undefined
The error is from the page.js file, in this function, at the second line:
function Context(path, state) {
    if ('/' === path[0] && 0 !== path.indexOf(base)) path = base + (hashbang ? '#!' : '') + path;
    var i = path.indexOf('?');
    this.canonicalPath = path;
    this.path = path.replace(base, '') || '/';
    if (hashbang) this.path = this.path.replace('#!', '') || '/';
    this.title = document.title;
    this.state = state || {};
    this.state.path = path;
    this.querystring = ~i ? decodeURLEncodedURIComponent(path.slice(i + 1)) : '';
    this.pathname = decodeURLEncodedURIComponent(~i ? path.slice(0, i) : path);
    this.params = {};
    // fragment
    this.hash = '';
    if (!hashbang) {
      if (!~this.path.indexOf('#')) return;
      var parts = this.path.split('#');
      this.path = parts[0];
      this.hash = decodeURLEncodedURIComponent(parts[1]) || '';
      this.querystring = this.querystring.split('#')[0];
    }
  }Anyone knows how i can manipulate history state, while using page.js?
Thanks