Просмотр исходного кода

refactor: update regex in matchSlashes function for improved path matching

Yuki Takei 10 месяцев назад
Родитель
Сommit
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 {