Skip to content

Commit

Permalink
Don't double encode filter values
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv committed Nov 7, 2024
1 parent 8faf1b4 commit ba5af22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"pestphp/pest": "^1.20",
"pestphp/pest-plugin-mock": "^1.0",
"phpstan/phpstan": "^1.9",
"spatie/invade": "^2.1",
"spatie/ray": "^1.28",
"vlucas/phpdotenv": "^5.5"
},
Expand Down
2 changes: 1 addition & 1 deletion src/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function buildFilterString(array $filters): string

$preparedFilters = [];
foreach ($filters as $name => $value) {
$preparedFilters["filter[{$name}]"] = urlencode($value);
$preparedFilters["filter[{$name}]"] = $value;
}

return '?'.http_build_query($preparedFilters);
Expand Down
11 changes: 11 additions & 0 deletions tests/MakesHttpRequestsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Spatie\MailcoachSdk\Mailcoach;

it('does not double encode', function () {
$mailcoach = new Mailcoach('fake-token', 'fake-uri');

expect(invade($mailcoach)->buildFilterString([
'email' => '[email protected]',
]))->toBe('?filter%5Bemail%5D=info%40spatie.be');
});

0 comments on commit ba5af22

Please sign in to comment.