ryoji-s преди 3 години
родител
ревизия
cc3b0cdea3
променени са 1 файла, в които са добавени 10 реда и са изтрити 5 реда
  1. 10 5
      packages/remark-lsx/src/server/routes/lsx.js

+ 10 - 5
packages/remark-lsx/src/server/routes/lsx.js

@@ -104,12 +104,17 @@ class Lsx {
     }
 
     let filterPath = '';
-    if (optionsFilter.charAt(0) === '^') {
-      // move '^' to the first of path
-      filterPath = new RegExp(`^${addTrailingSlash(pagePath)}${optionsFilter.slice(1, optionsFilter.length)}`);
+    try {
+      if (optionsFilter.charAt(0) === '^') {
+        // move '^' to the first of path
+        filterPath = new RegExp(`^${addTrailingSlash(pagePath)}${optionsFilter.slice(1, optionsFilter.length)}`);
+      }
+      else {
+        filterPath = new RegExp(`^${addTrailingSlash(pagePath)}.*${optionsFilter}`);
+      }
     }
-    else {
-      filterPath = new RegExp(`^${addTrailingSlash(pagePath)}.*${optionsFilter}`);
+    catch (err) {
+      throw createError(400, err);
     }
 
     if (isExceptFilter) {