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

Commit

Permalink
Merge pull request #2 from bmichotte/parenthesis
Browse files Browse the repository at this point in the history
Fix the use of parenthesis
  • Loading branch information
mpociot authored Jul 19, 2018
2 parents 23a43be + 8d62cf0 commit a4b85f4
Show file tree
Hide file tree
Showing 5 changed files with 664 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Xray.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function modifyView($view)

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

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

}
}
12 changes: 12 additions & 0 deletions tests/XrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public function it_does_not_apply_middleware_on_json_responses()

$this->get('/')->assertJson($data);
}

/** @test */
public function it_adds_xray_when_using_parenthesis_on_sections()
{
Route::get('/', function() {
return view('example2');
});

$response = $this->get('/');

$this->assertMatchesSnapshot($response->getContent());
}
}
Loading

0 comments on commit a4b85f4

Please sign in to comment.