From a8369e0f48b9a6c5b9914192bee7d542664271fc Mon Sep 17 00:00:00 2001 From: Baspa Date: Thu, 18 Jun 2026 14:59:47 +0200 Subject: [PATCH 1/2] fix: omit empty amount segment in filter() when no amount given --- src/Transformations/Filter.php | 6 +++++- tests/TransformationTest.php | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Transformations/Filter.php b/src/Transformations/Filter.php index 431fa1c..c47cc1c 100644 --- a/src/Transformations/Filter.php +++ b/src/Transformations/Filter.php @@ -48,7 +48,11 @@ public static function validate(string $key, ...$args): bool public static function generateUrl(string $url, array $values): string { // -/filter/:name/:amount/ - $url .= '-/filter/' . $values['name'] . '/' . $values['amount'] . '/'; + if ($values['amount'] === null) { + $url .= '-/filter/' . $values['name'] . '/'; + } else { + $url .= '-/filter/' . $values['name'] . '/' . $values['amount'] . '/'; + } return $url; } diff --git a/tests/TransformationTest.php b/tests/TransformationTest.php index 16082cc..599a10a 100644 --- a/tests/TransformationTest.php +++ b/tests/TransformationTest.php @@ -198,3 +198,14 @@ $url = (string) $transformation->stripMeta('sensitive'); expect($url)->toBe('https://ucarecdn.com/12a3456b-c789-1234-1de2-3cfa83096e25/-/strip_meta/sensitive/'); }); + +it('omits the amount segment in filter when no amount is given', function () { + $uuid = '12a3456b-c789-1234-1de2-3cfa83096e25'; + + $url = (string) uploadcare($uuid)->filter('adaris'); + expect($url)->toContain('-/filter/adaris/'); + expect($url)->not->toContain('adaris//'); + + $url = (string) uploadcare($uuid)->filter('adaris', 50); + expect($url)->toContain('-/filter/adaris/50/'); +}); From 1061e6b3c053c420e1e8da8255a7f634a0bd0192 Mon Sep 17 00:00:00 2001 From: Baspa Date: Thu, 18 Jun 2026 15:26:06 +0200 Subject: [PATCH 2/2] test: trigger workflow