Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeQuery returning wrong result #52

Closed
dmaicher opened this issue Oct 24, 2016 · 3 comments
Closed

MergeQuery returning wrong result #52

dmaicher opened this issue Oct 24, 2016 · 3 comments
Labels
bug Something isn't working

Comments

@dmaicher
Copy link

dmaicher commented Oct 24, 2016

Issue summary

The MergeQuery modifier returns wrong result since update from 4.1.1 to 4.2.0.

System informations

Information Description
League\Uri version 4.2.0
PHP version 5.6.22
OS Platform Debian 8

Standalone code, or other way to reproduce the problem

use League\Uri\Modifiers\MergeQuery;
use League\Uri\Schemes\Http;

class UrlQueryStringAppender
{
    /**
     * @param string $url
     * @param array  $queryParams
     *
     * @return string
     */
    public function appendToUrl($url, array $queryParams)
    {
        if (count($queryParams) === 0) {
            return $url;
        }

        $uri = Http::createFromString($url);
        $modifier = new MergeQuery(http_build_query($queryParams));

        return $modifier->__invoke($uri)->__toString();
    }
}
(new UrlQueryStringAppender())->appendToUrl('http://localhost?foo=foo&bar=%26foo#bar', [
    'foo' => '%bar'
])

Expected result

Should return http://localhost?foo=%25bar&bar=%26foo#bar

Actual result

Now returns http://localhost?foo=%BAr&bar=%26foo#bar

Problem appears since I updated from 4.1.1 to 4.2.0.

@nyamsprod nyamsprod added the bug Something isn't working label Oct 24, 2016
nyamsprod referenced this issue in thephpleague/uri Nov 11, 2016
nyamsprod referenced this issue in thephpleague/uri Nov 14, 2016
nyamsprod referenced this issue in thephpleague/uri Nov 14, 2016
@nyamsprod
Copy link
Member

@dmaicher the bug is fixed on the master branch can you confirm it so I close this issue on the next release.

@dmaicher
Copy link
Author

My test cases pass now 👍

@nyamsprod
Copy link
Member

version 4.2.1 is out which fixes this issue

@nyamsprod nyamsprod transferred this issue from thephpleague/uri Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants