Bug #1635

Routing: Routes should ignore query parameters if not configured

Added by Karsten Dambekalns about 13 years ago. Updated about 11 years ago.

Status:
Resolved
Priority:
Must have
Category:
MVC
Start date:
2008-10-02
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

Currently a route behaves weird if a query is given but not configured. Consider this example:

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]')
    ->setControllerComponentNamePattern('F3::@package::Service::Controller::@controllerController')
    ->setViewComponentNamePattern('F3::@package::Service::View::@controller::@action@format')
    ->setDefaults(
        array(
            '@package' => 'TYPO3',
        )
    );

Now calling the URLs as following results in...

http://site/typo3/service/v1/sites.json
=> correct output
http://site/typo3/service/v1/sites.json?something
=> An invalid request format (json?something) was given.

Not good. Trying to add ? to the end:

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]?')

Still the same results.

Workaround: add "?[@dummy]" to the pattern, and it works.

$c->TYPO3Route_ServiceWithControllerAndFormat
    ->setUrlPattern('typo3/service/v1/[@controller].[@format]?[@dummy]')

Expected solution:
  • ignore a query if not needed
#1

Updated by Bastian Waidelich about 13 years ago

Todo: When a query string is given in the UriPattern, this should be matched exactly. If not, query strings are ignored.

#2

Updated by Bastian Waidelich about 13 years ago

  • Target version set to 1.0 alpha 1
#3

Updated by Bastian Waidelich about 13 years ago

  • Subject changed from Routes should ignore query parameters if not configured to Routing: Routes should ignore query parameters if not configured
#4

Updated by Karsten Dambekalns almost 13 years ago

  • Target version deleted (1.0 alpha 1)
#5

Updated by Karsten Dambekalns almost 13 years ago

  • Target version set to 1.0 alpha 1
#6

Updated by Bastian Waidelich almost 13 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r1408.

#7

Updated by Bastian Waidelich almost 13 years ago

NOTE Behavior of queries in Routes will change:
Query strings won't be part of the URI patterns anymore to avoid complexity of configuration and implementation.
Instead, query strings will be ignored when matching routes. All query parameters will be passed through to the current request object.
When building URIs, remaining Route values will be added to the query string in the format:

?key1=value1&key2=value2

Also available in: Atom PDF