fix router when self.history or self.history.length is undefoned