Skip to content

Commit d605556

Browse files
author
Peter Bengtsson
authored
encode 'query' in 'redirectQuery' (#22913)
1 parent 5d55bd8 commit d605556

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

components/Search.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function ShowSearchResults({
277277
results: SearchResult[] | undefined
278278
closeSearch: () => void
279279
debug: boolean
280-
query: string | string[]
280+
query: string
281281
}) {
282282
const { t } = useTranslation('search')
283283
const router = useRouter()
@@ -296,7 +296,13 @@ function ShowSearchResults({
296296
version: version,
297297
}
298298
})
299-
const redirectQuery = query ? `?query=${query}` : ''
299+
300+
const redirectParams: {
301+
query: string
302+
debug?: string
303+
} = { query }
304+
if (debug) redirectParams.debug = JSON.stringify(debug)
305+
const redirectQuery = `?${new URLSearchParams(redirectParams).toString()}`
300306

301307
if (results) {
302308
if (results.length === 0) {
@@ -348,7 +354,7 @@ function ShowSearchResults({
348354
renderItem: () => (
349355
<ActionList.Item as="div">
350356
<Link href={url} className="no-underline color-fg-default">
351-
<li key={url} data-testid="search-result" className={cx('list-style-none')}>
357+
<li data-testid="search-result" className={cx('list-style-none')}>
352358
<div className={cx('py-2 px-3')}>
353359
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
354360
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>

0 commit comments

Comments
 (0)