Explorar o código

Escape string in regex using library

arvid-e hai 3 meses
pai
achega
dfa9d1ba00
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      packages/remark-lsx/src/server/routes/list-pages/index.ts

+ 1 - 1
packages/remark-lsx/src/server/routes/list-pages/index.ts

@@ -95,7 +95,7 @@ export const listPages = ({ excludedPaths }: { excludedPaths: string[] }) => {
       if (excludedPaths.length > 0) {
         const escapedPaths = excludedPaths.map((p) => {
           const cleanPath = p.startsWith('/') ? p.substring(1) : p;
-          return cleanPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+          return escapeStringRegexp(cleanPath);
         });
 
         const regex = new RegExp(`^\\/(${escapedPaths.join('|')})(\\/|$)`);