Skip to content

Commit

Permalink
Bug fix #133
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Mar 23, 2024
1 parent 63796b0 commit c562e4a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

All Notable changes to `League\Uri\Components` will be documented in this file

## [Next](https://github.com/thephpleague/uri-components/compare/7.4.0...master) - TBD

### Added

- None

### Fixed

- Fix package to avoid PHP8.4 deprecation warnings
- Bug Fix `removeEmptyPairs` [#133](https://github.com/thephpleague/uri-src/issues/133)

### Deprecated

- None

### Removed

- None

## [7.4.0](https://github.com/thephpleague/uri-components/compare/7.3.0...7.4.0) - 2023-12-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion UriModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function removePairs(Psr7UriInterface|UriInterface $uri, string ..
*/
public static function removeEmptyPairs(Psr7UriInterface|UriInterface $uri): Psr7UriInterface|UriInterface
{
return Modifier::from($uri)->removeQueryPairsByKey()->getUri();
return Modifier::from($uri)->removeEmptyQueryPairs()->getUri();
}

/**
Expand Down
29 changes: 29 additions & 0 deletions UriModifierTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* League.Uri (https://uri.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace League\Uri;

use PHPUnit\Framework\TestCase;

final class UriModifierTest extends TestCase
{
/** @test */
public function it_will_remove_empty_pairs_fix_issue_133(): void
{
$removeEmptyPairs = fn (string $str): ?string => UriModifier::removeEmptyPairs(Http::createFromString($str))->getQuery(); /* @phpstan-ignore-line */

self::assertSame('', $removeEmptyPairs('https://a.b/c?d='));
self::assertSame('', $removeEmptyPairs('https://a.b/c?=d'));
self::assertSame('', $removeEmptyPairs('https://a.b/c?='));
}
}

0 comments on commit c562e4a

Please sign in to comment.