From 68a91f0381c32b6ad88e127a78724d1cbb9c8537 Mon Sep 17 00:00:00 2001 From: Yug Bhanushali Date: Tue, 7 Nov 2023 20:03:27 +0530 Subject: [PATCH] fixes quotes in search result (using cmdk) crashes the application (#18302) * fixed quotes in search result (using cmdk) crashes the application * fixed quotes in search result (using cmdk) crashes the application * fixes quotes in search result (using cmdk) crashes the application --- packages/ui/src/components/Command/DocsSearch.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/Command/DocsSearch.tsx b/packages/ui/src/components/Command/DocsSearch.tsx index a3d11cddeb5..14223bea2ef 100644 --- a/packages/ui/src/components/Command/DocsSearch.tsx +++ b/packages/ui/src/components/Command/DocsSearch.tsx @@ -49,6 +49,11 @@ export interface PageResult { sections: PageSection[] } +function removeDoubleQuotes(inputString: string): string { + // Use the replace method with a regular expression to remove double quotes + return inputString.replace(/"/g, '') +} + const getDocsUrl = () => { if (!process.env.NEXT_PUBLIC_SITE_URL || !process.env.NEXT_PUBLIC_LOCAL_SUPABASE) { return 'https://supabase.com/docs' @@ -171,7 +176,7 @@ const DocsSearch = () => { > { openLink(page.type, formatPageUrl(page)) @@ -202,7 +207,9 @@ const DocsSearch = () => { openLink(page.type, formatSectionUrl(page, section)) }} key={`${page.meta.title}__${section.heading}-item-index-${i}`} - value={`${page.meta.title}__${section.heading}-item-index-${i}`} + value={`${removeDoubleQuotes(page.meta.title)}__${removeDoubleQuotes( + section.heading ?? '' + )}-item-index-${i}`} type="block-link" >