فهرست منبع

refactor: update regex in matchSlashes function for improved path matching

Yuki Takei 1 سال پیش
والد
کامیت
f5a186821c
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      packages/core/src/utils/path-utils.ts

+ 2 - 2
packages/core/src/utils/path-utils.ts

@@ -1,6 +1,6 @@
 function matchSlashes(path: string): RegExpMatchArray | null {
-  // https://regex101.com/r/Z21fEd/5
-  return path.match(/^((\/+)?(.+?))(\/+)?$/);
+  // https://regex101.com/r/FzHxQ9/1
+  return path.match(/^(?=\/|[^\n])((\/+)?([^\n]+?))(\/+)?$/);
 }
 
 export function hasHeadingSlash(path: string): boolean {