Skip to content

Commit 519891f

Browse files
committed
refactor: improve regex for stripping history highlight spans to handle all content types
1 parent 57403ae commit 519891f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

webview-ui/src/components/history/CopyButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ type CopyButtonProps = {
1717
* @returns Text with highlight spans removed but content preserved
1818
*/
1919
const stripHistoryHighlightSpans = (text: string): string => {
20-
// Use regex to specifically target history-item-highlight spans
21-
// This preserves other HTML/XML that might be intentional
22-
return text.replace(/<span\s+class="history-item-highlight">([^<]*)<\/span>/g, "$1")
20+
// Match opening tag, capture content until closing tag
21+
// The [\s\S]*? pattern matches any character (including newlines) non-greedily,
22+
// which properly handles content with < characters
23+
return text.replace(/<span\s+class="history-item-highlight">([\s\S]*?)<\/span>/g, "$1")
2324
}
2425

2526
export const CopyButton = ({ itemTask, className }: CopyButtonProps) => {

0 commit comments

Comments
 (0)