(function() {
  var routePath = window.__H5_ROUTE_PATH__;
  if (!routePath) {
    return;
  }

  var currentHash = window.location.hash ? window.location.hash.slice(1) : "";
  if (currentHash === routePath || currentHash.indexOf(routePath + "?") === 0) {
    return;
  }

  var nextHash = routePath + (window.location.search || "");
  window.history.replaceState(
    null,
    "",
    window.location.pathname + (window.location.search || "") + "#" + nextHash
  );
})();
