typesense / docusaurus-theme-search-typesense

A fork of the awesome @docusaurus/theme-search-algolia library customized to work with Typesense
https://typesense.org/docs/guide/docsearch.html
MIT License
67 stars 15 forks source link

Take into account url query params (url.search) into results #48

Open devstgo opened 4 months ago

devstgo commented 4 months ago

Description

Query params are not used when SearchBar and SearchPage adapt the url from Typesense server response to docusaurus component.

Steps to reproduce

Scrap a website with some url with query params Do a search in docusaurus Check that response from typesense server return the query param in the response Inspect the docusaurus href link and verify that link skips query params.

Expected Behavior

The href field has to take into account the query params

Actual Behavior

The actual code only has into account pathname and hash.

docusaurus-theme-search-typesense/src/theme/SearchPage/index.tsx line 284 concat parsedURL.search:

            url: isRegexpStringMatch(externalUrlRegex, parsedURL.href)
              ? parsedURL.href
              : parsedURL.pathname + parsedURL.search +  parsedURL.hash,

In the same way, we had to do the same modification into docusaurus-theme-search-typesense/src/theme/SearchBar/index.tsx at line 193:

url: withBaseUrl(`${url.pathname}${url.search}${url.hash}`),