Kaynağa Gözat

refactor: update regex in matchSlashes function for improved path matching

Yuki Takei 10 ay önce
ebeveyn
işleme
f5a186821c
1 değiştirilmiş dosya ile 2 ekleme ve 2 silme
  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 {