Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spatie/browsershot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.1.2
Choose a base ref
...
head repository: spatie/browsershot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.1.3
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 15, 2024

  1. Fix styling

    freekmurze authored and github-actions[bot] committed Jul 15, 2024
    Copy the full SHA
    4204ea9 View commit details
  2. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Jul 15, 2024
    Copy the full SHA
    8700309 View commit details
  3. dev

    ziaratban authored and freekmurze committed Jul 15, 2024
    Copy the full SHA
    00ed681 View commit details
Showing with 45 additions and 3 deletions.
  1. +13 −0 CHANGELOG.md
  2. +5 −3 bin/browser.cjs
  3. +6 −0 src/Browsershot.php
  4. +21 −0 tests/BrowsershotTest.php
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 4.1.2 - 2024-07-15

### What's Changed

* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/spatie/browsershot/pull/860
* Fix - Clean up the temporary options file when browser was called successfully by @Ardenexal in https://github.com/spatie/browsershot/pull/863

### New Contributors

* @Ardenexal made their first contribution in https://github.com/spatie/browsershot/pull/863

**Full Changelog**: https://github.com/spatie/browsershot/compare/4.1.1...4.1.2

## 4.1.1 - 2024-07-03

### What's Changed
8 changes: 5 additions & 3 deletions bin/browser.cjs
Original file line number Diff line number Diff line change
@@ -158,9 +158,11 @@ const callChrome = async pup => {
page.on('request', interceptedRequest => {
var headers = interceptedRequest.headers();

requestsList.push({
url: interceptedRequest.url(),
});
if (request.options && request.options.disableCaptureURLS) {
requestsList.push({
url: interceptedRequest.url(),
});
}

if (request.options && request.options.disableImages) {
if (interceptedRequest.resourceType() === 'image') {
6 changes: 6 additions & 0 deletions src/Browsershot.php
Original file line number Diff line number Diff line change
@@ -457,6 +457,11 @@ public function disableImages(): static
return $this->setOption('disableImages', true);
}

public function disableCaptureURLS(): static
{
return $this->setOption('disableCaptureURLS', true);
}

public function blockUrls($array): static
{
return $this->setOption('blockUrls', $array);
@@ -1048,6 +1053,7 @@ protected function callBrowser(array $command): string
$result = $this->chromiumResult?->getResult();

$this->cleanupTemporaryOptionsFile();

return $result;
}

21 changes: 21 additions & 0 deletions tests/BrowsershotTest.php
Original file line number Diff line number Diff line change
@@ -222,6 +222,27 @@
], $command);
});

it('can disable capture urls', function () {
$command = Browsershot::url('https://example.com')
->disableCaptureURLS()
->createScreenshotCommand('screenshot.png');

$this->assertEquals([
'url' => 'https://example.com',
'action' => 'screenshot',
'options' => [
'disableCaptureURLS' => true,
'path' => 'screenshot.png',
'viewport' => [
'width' => 800,
'height' => 600,
],
'args' => [],
'type' => 'png',
],
], $command);
});

it('can block urls', function () {
$command = Browsershot::url('https://example.com')
->blockUrls([