Skip to content

Commit 53b90d0

Browse files
committed
Add support for FragmentDirective on League\Uri\Uri
1 parent e708635 commit 53b90d0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

uri/Uri.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Deprecated;
1818
use finfo;
1919
use League\Uri\Contracts\Conditionable;
20+
use League\Uri\Contracts\FragmentDirective;
2021
use League\Uri\Contracts\UriComponentInterface;
2122
use League\Uri\Contracts\UriException;
2223
use League\Uri\Contracts\UriInterface;
@@ -1490,6 +1491,10 @@ public function withQuery(Stringable|string|null $query): static
14901491

14911492
public function withFragment(Stringable|string|null $fragment): static
14921493
{
1494+
if ($fragment instanceof FragmentDirective) {
1495+
$fragment = ':~:'.$fragment->toString();
1496+
}
1497+
14931498
$fragment = Encoder::encodeQueryOrFragment($this->filterString($fragment));
14941499

14951500
return match ($fragment) {

0 commit comments

Comments
 (0)