Skip to content

Commit

Permalink
improvement: omit ? in instantsearch urls when no queryargs present
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstadler committed Jan 7, 2025
1 parent 1c932d4 commit c1365e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/instantsearch/instantsearchprovider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function InstantSearchProvider(props: InstantSearchProviderProps): ReactN
if (parts.at(-1) !== pageName) {
parts.pop();
}
// don't add value if it is undefined
if (pathnameField && routeState[pathnameField]) {
parts.push(routeState[pathnameField]);

Expand All @@ -48,7 +49,8 @@ export function InstantSearchProvider(props: InstantSearchProviderProps): ReactN
delete routeState[pathnameField];
}
}
return `${parts.join("/")}?${qsModule.stringify(routeState)}`;
const qa = qsModule.stringify(routeState);
return parts.join("/") + (qa && `?${qa}`);
},
parseURL({ qsModule, location }) {
const queryArgs = qsModule.parse(location.search.slice(1));
Expand Down

0 comments on commit c1365e1

Please sign in to comment.