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

Also available in: Atom PDF