mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix: escape regex special character
This commit is contained in:
@@ -4,7 +4,7 @@ import React, { useState, useRef, useCallback, useMemo } from "react"
|
||||
import { Command, CommandGroup, CommandItem, CommandList } from "@/components/ui/command"
|
||||
import { Command as CommandPrimitive } from "cmdk"
|
||||
import { motion, AnimatePresence } from "framer-motion"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn, searchSafeRegExp } from "@/lib/utils"
|
||||
|
||||
interface GraphNode {
|
||||
name: string
|
||||
@@ -27,7 +27,8 @@ export function Autocomplete({ topics = [], onSelect, onInputChange }: Autocompl
|
||||
if (!inputValue) {
|
||||
return topics.slice(0, 5)
|
||||
}
|
||||
const regex = new RegExp(inputValue.split("").join(".*"), "i")
|
||||
|
||||
const regex = searchSafeRegExp(inputValue)
|
||||
return topics.filter(
|
||||
topic =>
|
||||
regex.test(topic.name) ||
|
||||
|
||||
Reference in New Issue
Block a user