Skip to content

Commit f565e39

Browse files
authored
Fix: Add missing argument 'except' to function 'url' in state properties (#89)
1 parent 37dc733 commit f565e39

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/Options/StateOptions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function reactive(): static
7070
/**
7171
* Indicate the state should be tracked in the URL.
7272
*/
73-
public function url(?string $as = null, ?bool $history = null, ?bool $keep = null): static
73+
public function url(?string $as = null, ?bool $history = null, ?bool $keep = null, ?string $except = null): static
7474
{
75-
return $this->attribute(Url::class, as: $as, history: $history, keep: $keep);
75+
return $this->attribute(Url::class, as: $as, history: $history, keep: $keep, except: $except);
7676
}
7777
}

tests/Feature/Compiler/UrlTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
state('searchOne')->url();
1616
state('searchTwo')->url(as: 'search', history: true);
1717
state('searchThree')->url(keep: true);
18+
state('searchFour')->url(keep: true, except: '');
1819

1920
$code = Compiler::contextToString(CompileContext::instance());
2021

21-
expect($code)->toContain(<<<'PHP'
22+
expect($code)->toContain(
23+
<<<'PHP'
2224
#[\Livewire\Attributes\Url()]
2325
public $searchOne;
2426
@@ -27,6 +29,9 @@
2729
2830
#[\Livewire\Attributes\Url(keep: true)]
2931
public $searchThree;
32+
33+
#[\Livewire\Attributes\Url(keep: true, except: '')]
34+
public $searchFour;
3035
PHP
3136
);
3237
});

tests/Feature/CompilerContext/UrlTest.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
state(searchOne: 1)->url();
1414
state(searchTwo: 2)->url(as: 'search', history: true);
1515
state(searchThree: 3)->url(keep: true);
16+
state(searchFour: 4)->url(keep: true, except: '');
1617

17-
expect($context->state)->toHaveKeys(['name', 'searchOne', 'searchTwo', 'searchThree'])
18+
expect($context->state)->toHaveKeys(['name', 'searchOne', 'searchTwo', 'searchThree', 'searchFour'])
1819
->sequence(
1920
fn (Expectation $property) => $property->attributes->toBe([]),
2021
fn (Expectation $property) => $property->attributes->toBe([
@@ -31,5 +32,11 @@
3132
'keep' => true,
3233
],
3334
]),
35+
fn (Expectation $property) => $property->attributes->toBe([
36+
Url::class => [
37+
'keep' => true,
38+
'except' => '',
39+
],
40+
]),
3441
);
3542
});

0 commit comments

Comments
 (0)