Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 8d62cf0

Browse files
committed
Fix the use of parenthesis
1 parent 23a43be commit 8d62cf0

File tree

5 files changed

+664
-2
lines changed

5 files changed

+664
-2
lines changed

src/Xray.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function modifyView($view)
3434

3535
$file = tempnam(sys_get_temp_dir(), $view->name());
3636

37-
$re = '/(@section\(([^))]+)\))(.*?)(@endsection|@show|@overwrite)/s';
37+
$re = '/(@section\(([^))]+)\)+)(.*?)(@endsection|@show|@overwrite)/s';
3838
$viewContent = preg_replace_callback($re, function ($matches) use ($view) {
3939
++$this->viewId;
4040
$sectionName = str_replace(["'", '"'], '', $matches[2]);
@@ -60,4 +60,4 @@ protected function isEnabledForView(string $viewName): bool
6060
return ! in_array($viewName, config('xray.excluded', []));
6161
}
6262

63-
}
63+
}

tests/XrayTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@ public function it_does_not_apply_middleware_on_json_responses()
3434

3535
$this->get('/')->assertJson($data);
3636
}
37+
38+
/** @test */
39+
public function it_adds_xray_when_using_parenthesis_on_sections()
40+
{
41+
Route::get('/', function() {
42+
return view('example2');
43+
});
44+
45+
$response = $this->get('/');
46+
47+
$this->assertMatchesSnapshot($response->getContent());
48+
}
3749
}

0 commit comments

Comments
 (0)