Skip to content

[Routing] fixed route generation when pattern already has question mark #4191

wants to merge 1 commit into from

3 participants


Bug fix: yes
Feature addition: no
Backwards compatibility break: If someone relied no this bug, yes
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

I sometimes have routes like the following used purely for generating a url, whether that be to the symfony app or an external app:

    pattern:  /blog/?category=news

When generating this route with extra parameters, the url it generates is invalid.

$router->generate('blog_news', array('page' => 2));
// results in /blog/?category=news?page=2

I've changed the generator to use & if the url already has a ?

Symfony member
fabpot commented May 3, 2012

The route pattern is just about the URL path, and as such it must not contain the query string.

Symfony member
Tobion commented May 3, 2012

The question mark in the path should be encoded. See #4166.
Then the route will be valid. But as fabpot said, the query string doesn't belong in the route pattern anyway.


Yea you're right, I didn't think that one through enough. Thanks for the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.