function resolveHref(router, href, resolveAs) {
  // we use a dummy base url for relative urls
  var base;
  var urlAsString = typeof href === 'string' ? href : (0, _utils.formatWithValidation)(href);

  try {
    base = new URL(urlAsString.startsWith('#') ? router.asPath : router.pathname, 'http://n');
  } catch (_) {
    // fallback to / for invalid asPath values e.g. //
    base = new URL('/', 'http://n');
  } // Return because it cannot be routed by the Next.js router


  if (!isLocalURL(urlAsString)) {
    return resolveAs ? [urlAsString] : urlAsString;
  }

  try {
    var finalUrl = new URL(urlAsString, base);
    finalUrl.pathname = (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(finalUrl.pathname);
    var interpolatedAs = '';

    if ((0, _isDynamic.isDynamicRoute)(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
      var query = (0, _querystring.searchParamsToUrlQuery)(finalUrl.searchParams);

      var _interpolateAs = interpolateAs(finalUrl.pathname, finalUrl.pathname, query),
          result = _interpolateAs.result,
          params = _interpolateAs.params;

      if (result) {
        interpolatedAs = (0, _utils.formatWithValidation)({
          pathname: result,
          hash: finalUrl.hash,
          query: omitParmsFromQuery(query, params)
        });
      }
    } // if the origin didn't change, it means we received a relative href


    var resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
    return resolveAs ? [resolvedHref, interpolatedAs || resolvedHref] : resolvedHref;
  } catch (_) {
    return resolveAs ? [urlAsString] : urlAsString;
  }
}
/**
* Resolves a given hyperlink with a certain router state (basePath not included).
* Preserves absolute urls.
*/
Resolves a given hyperlink with a certain router state (basePath not included).
Preserves absolute urls.
Resolves a given hyperlink with a certain router state ( basePath not included ) . Preserves absolute urls .
function resolveHref(router, href, resolveAs) {
  var base;
  var urlAsString = typeof href === 'string' ? href : (0, _utils.formatWithValidation)(href);
  try {
    base = new URL(urlAsString.startsWith('#') ? router.asPath : router.pathname, 'http://n');
  } catch (_) {
    base = new URL('/', 'http://n');
  } 
  if (!isLocalURL(urlAsString)) {
    return resolveAs ? [urlAsString] : urlAsString;
  }
  try {
    var finalUrl = new URL(urlAsString, base);
    finalUrl.pathname = (0, _normalizeTrailingSlash.normalizePathTrailingSlash)(finalUrl.pathname);
    var interpolatedAs = '';
    if ((0, _isDynamic.isDynamicRoute)(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
      var query = (0, _querystring.searchParamsToUrlQuery)(finalUrl.searchParams);
      var _interpolateAs = interpolateAs(finalUrl.pathname, finalUrl.pathname, query),
          result = _interpolateAs.result,
          params = _interpolateAs.params;
      if (result) {
        interpolatedAs = (0, _utils.formatWithValidation)({
          pathname: result,
          hash: finalUrl.hash,
          query: omitParmsFromQuery(query, params)
        });
      }
    } 
    var resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
    return resolveAs ? [resolvedHref, interpolatedAs || resolvedHref] : resolvedHref;
  } catch (_) {
    return resolveAs ? [urlAsString] : urlAsString;
  }
}
function resolveHref ( router , href , resolveAs ) { var base ; var urlAsString = typeof href === 'string' ? href : ( 0 , _utils . formatWithValidation ) ( href ) ; try { base = new URL ( urlAsString . startsWith ( '#' ) ? router . asPath : router . pathname , 'http://n' ) ; } catch ( _ ) { base = new URL ( '/' , 'http://n' ) ; } if ( ! isLocalURL ( urlAsString ) ) { return resolveAs ? [ urlAsString ] : urlAsString ; } try { var finalUrl = new URL ( urlAsString , base ) ; finalUrl . pathname = ( 0 , _normalizeTrailingSlash . normalizePathTrailingSlash ) ( finalUrl . pathname ) ; var interpolatedAs = '' ; if ( ( 0 , _isDynamic . isDynamicRoute ) ( finalUrl . pathname ) && finalUrl . searchParams && resolveAs ) { var query = ( 0 , _querystring . searchParamsToUrlQuery ) ( finalUrl . searchParams ) ; var _interpolateAs = interpolateAs ( finalUrl . pathname , finalUrl . pathname , query ) , result = _interpolateAs . result , params = _interpolateAs . params ; if ( result ) { interpolatedAs = ( 0 , _utils . formatWithValidation ) ( { pathname : result , hash : finalUrl . hash , query : omitParmsFromQuery ( query , params ) } ) ; } } var resolvedHref = finalUrl . origin === base . origin ? finalUrl . href . slice ( finalUrl . origin . length ) : finalUrl . href ; return resolveAs ? [ resolvedHref , interpolatedAs || resolvedHref ] : resolvedHref ; } catch ( _ ) { return resolveAs ? [ urlAsString ] : urlAsString ; } }
Resolves a given hyperlink with a certain router state (basePath not included).
Resolves a given hyperlink with a certain router state ( basePath not included ) .
// we use a dummy base url for relative urls // fallback to / for invalid asPath values e.g. // // Return because it cannot be routed by the Next.js router // if the origin didn't change, it means we received a relative href