Instantsearch.js historyRouter CreateURL fires after vue exits

I have created a router using historyRouter with CreateURL, parseURL, siteMapping, etc. It all works great except when the user navigates to another page or hits the back button out of the search page CreateURL fires and appends ‘/search’ to the url causing confusion.

Here is my CreateURL functions.

      createURL({ qsModule, routeState, location }) {
      const urlParts = location.href.match(/^(.*?)\/search/);
      const baseUrl = `${urlParts ? urlParts[1] : ""}/`;


      let queryParameters = {};
      if (routeState.query) {
        queryParameters.query = encodeURIComponent(routeState.query);
      }

      if (routeState.refinementList) {
        queryParameters = routeState.refinementList;
      }

      const queryString = qsModule.stringify(queryParameters, {
        addQueryPrefix: true,
        arrayFormat: "repeat",
      });
      return `${baseUrl}search${queryString}`;
    },

Probably a better way to do this but just wrapped the return inside an if to check if there is a queryString.