   #
   # Push new state to the stack, do not reload
   pushState: (state, title, url)->
-    url = URL.resolve(@_stack[@_index]?.url, url)
+    url = @_resolve(url)
     @_stack[++@_index] = new Entry(this, url, { state: state, title: title, pop: true })
 
   # ### history.replaceState(state, title, url)

  _submit: (url, method, data, enctype)->
    headers = { "content-type": enctype || "application/x-www-form-urlencoded" }
    @_stack = @_stack[0..@_index]
    url = URL.resolve(@_stack[@_index]?.url, url)
    @_stack[++@_index] = new Entry(this, url)
    @_resource @_stack[@_index].url, method, data, headers


  # Replace existing state in the stack, do not reload
  replaceState: (state, title, url)->
    @_index = 0 if @_index < 0
    url = @_resolve(url)
    @_stack[@_index] = new Entry(this, url, { state: state, title: title, pop: true })

  # Resolve URL based on current page URL.
  _resolve: (url)->
    if url
      return URL.resolve(@_stack[@_index]?.url, url)
    else # Yes, this could happen
      return @_stack[@_index]?.url

  # Location uses this to move to a new URL.
  _assign: (url)->
    url = @_resolve(url)
    was = @_stack[@_index]?.url # before we destroy stack
    @_stack = @_stack[0..@_index]
    @_stack[++@_index] = new Entry(this, url)
