File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
.playground/pages/tests/form Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ const hobbies: Hobby[] = [
8484 },
8585 {
8686 id: 5 ,
87- name: ' Karaoke' ,
87+ name: ' Karaoke (with friends) ' ,
8888 text: ' singing with friends' ,
8989 icon: ' ph:microphone-stage-duotone' ,
9090 },
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ import type { MaybeRefOrGetter } from 'vue'
22
33import { escapeHtml } from '@vue/shared'
44
5+ function escapeRegExp ( literal : string ) : string {
6+ return literal . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' )
7+ }
8+
59export function useNinjaMark (
610 _text ?: MaybeRefOrGetter < string | undefined > ,
711 _search ?: MaybeRefOrGetter < string | undefined > ,
@@ -22,7 +26,7 @@ export function useNinjaMark(
2226 return escapeHtml ( txt )
2327 }
2428
25- const regex = new RegExp ( srch , 'gi' )
29+ const regex = new RegExp ( escapeRegExp ( srch ) , 'gi' )
2630
2731 return txt . replace ( regex , ( part ) => {
2832 return `<mark class="${ classes . value } ">${ escapeHtml ( part ) } </mark>`
You can’t perform that action at this time.
0 commit comments