Răsfoiți Sursa

Escape string in regex using library

arvid-e 3 luni în urmă
părinte
comite
dfa9d1ba00

+ 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('|')})(\\/|$)`);