export const normalizeRouteStateQuery = (query = {}) => { const viewAll = query?.va === "true"; const advanced = query?.adv === "true"; const address = query?.ads === "true"; return { viewAll, advanced, address, key: query?.key }; }; export const resolveSearchResultsHref = ({ query = {}, hasSession = false, includeViewAll = true, fallbackToMyPortalWhenNoFlags = false, isDnsRoute = false } = {}) => { const routeState = normalizeRouteStateQuery(query); const { viewAll, advanced, address, key } = routeState; const base = hasSession ? "/myportal" : ""; if (fallbackToMyPortalWhenNoFlags && !viewAll && !advanced && !address) { return { pathname: "/myportal" }; } if (isDnsRoute) { return { pathname: `${base}/dnsapplications` }; } if (includeViewAll && viewAll) { return { pathname: "/myportal/viewall", query: { key } }; } if (advanced) { return { pathname: `${base}/advancedsearchresults`, query }; } if (address) { return { pathname: `${base}/addresssearchresults`, query }; } return { pathname: `${base}/searchresults`, query }; };