Browse Source

Escape string in regex using library

arvid-e 3 months ago
parent
commit
dfa9d1ba00
1 changed files with 1 additions and 1 deletions
  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('|')})(\\/|$)`);