Keep query and fragment on Ask AI answer links (#64050) · github/docs@a2a327a · GitHub
Skip to content

Commit a2a327a

Browse files
heiskrCopilot
andauthored
Keep query and fragment on Ask AI answer links (#64050)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bf5940de-658e-4a1a-bffa-3018fb78b138
1 parent bbf8e29 commit a2a327a

3 files changed

Lines changed: 70 additions & 16 deletions

File tree

Lines changed: 15 additions & 0 deletions

‎src/frame/components/ui/MarkdownContent/UnrenderedMarkdownContent.tsx‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useTranslation } from '@/languages/components/useTranslation'
1111
import useCopyClipboard from '@/rest/components/useClipboard'
1212
import { EventType } from '@/events/types'
1313
import { sendEvent } from '@/events/components/events'
14+
import { addFeatureParamToHref } from '@/frame/components/lib/add-feature-param-to-href'
1415

1516
import styles from './MarkdownContent.module.scss'
1617

@@ -94,22 +95,9 @@ export const UnrenderedMarkdownContent = ({
9495

9596
// Custom anchors preserve feature query params and can force links into new tabs.
9697
components.a = ({ ...props }) => {
97-
let href = props.href || ''
98-
let existingAnchorParams = ''
99-
if (includeQueryParams) {
100-
if (href.includes('?')) {
101-
href = href.split('?')[0]
102-
existingAnchorParams = href.split('?')[1]
103-
}
104-
const existingURLParams = new URLSearchParams(window.location.search)
105-
const newParams = new URLSearchParams()
106-
if (existingURLParams.get('feature')) {
107-
newParams.set('feature', existingURLParams.get('feature') || '')
108-
}
109-
if (newParams.toString()) {
110-
href = `${href}?${existingAnchorParams}&${newParams.toString()}`
111-
}
112-
}
98+
const href = includeQueryParams
99+
? addFeatureParamToHref(props.href || '', window.location.search)
100+
: props.href || ''
113101
return (
114102
<a
115103
{...props}
Lines changed: 51 additions & 0 deletions

0 commit comments

Comments
 (0)