HTML5 History API - не получается сменить url

Ситуация такова: страница открывается по адресу mydomen/dir1/dir2/page.html

1) Жмем кнопку 1 и получаем URL mydomen/dir1/dir2/bbb как и хотелось

2) Затем жмем кнопку 2 и получаем URL mydomen/bbb а хотелось mydomen/dir1/dir2/bbb/bbb

Подскажите пожалуйста, как достичь желаемого результата?

function nextPage(curLoc){
        try {
            history.pushState({'page':curLoc,'oldPage':location.pathname.split("/").pop()}, event.target.innerText, curLoc);
            goEndPath = location.pathname.split("/").pop();
            return;
          } catch(e) {}
          location.hash = '#' + curLoc;
      }
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <button onclick="nextPage('bbb')">Кнопка 1</button>
    <button onclick="nextPage('/bbb')">Кнопка 2</button>
  </body>
</html>


Ответы (0 шт):